Hello!
I've encountered a problem with ListGrids that have cell-level selection enabled and contain cells which consist of a custom record component. Obviously, these cells don't get selected and don't receive focus when they are clicked on.
The following sample code exemplifies the problem. It contains a simple ListGrid with cell selection enabled comprising three rows and three columns, where the third column consists of a custom record component (a VLayout with a Label inside). The cells in the fields F1 and F2 behave as expected: You can click them, they get selected and you can start navigating within the ListGrid by using arrow keys. However, when clicking on a cell in F3, nothing happens and the previously selected cell in F1 or F2 stays selected.
So my question is if there is a way to get the cells in F3 act like "normal" cells without custom record components, so that they get selected when being clicked on?
I've implemented a first workaround and added a ClickHandler to the VLayout. However, this only solves one part of the problem: The cell gets indeed selected, but obviously it doesn't get the (keyboard) focus. When you use the arrow keys, the navigation starts from the previously selected cell in F1 or F2 (if any cell has been selected before), which is really odd behavior.
Do you have any other suggestions?
I would really appreciate your help in this matter. Thank you!
Smart GWT version:
v9.0p_2013-08-29/PowerEdition Deployment (built 2013-08-29)
Browsers:
Firefox 23.0.1
IE 9
I've encountered a problem with ListGrids that have cell-level selection enabled and contain cells which consist of a custom record component. Obviously, these cells don't get selected and don't receive focus when they are clicked on.
The following sample code exemplifies the problem. It contains a simple ListGrid with cell selection enabled comprising three rows and three columns, where the third column consists of a custom record component (a VLayout with a Label inside). The cells in the fields F1 and F2 behave as expected: You can click them, they get selected and you can start navigating within the ListGrid by using arrow keys. However, when clicking on a cell in F3, nothing happens and the previously selected cell in F1 or F2 stays selected.
Code:
ListGrid grid = new ListGrid() { @Override protected Canvas createRecordComponent(final ListGridRecord record, final Integer colNum) { if (colNum == 2) { VLayout layout = new VLayout(); layout.setHeight(30); layout.setAlign(Alignment.CENTER); Label label = new Label("XYZ"); label.setHeight(20); layout.addMember(label); return layout; } else { return super.createRecordComponent(record, colNum); } } }; grid.setCanSelectCells(true); grid.setSelectionType(SelectionStyle.SINGLE); grid.setShowRollOver(false); grid.setShowRecordComponents(true); grid.setShowRecordComponentsByCell(true); grid.setWidth(400); grid.setHeight(120); ListGridField field1 = new ListGridField("F1"); ListGridField field2 = new ListGridField("F2"); ListGridField field3 = new ListGridField("F3"); grid.setFields(field1, field2, field3); Record r1 = new Record(); r1.setAttribute("F1", "Test1"); r1.setAttribute("F2", "Test2"); Record r2 = new Record(); r2.setAttribute("F1", "Test3"); r2.setAttribute("F2", "Test4"); Record r3 = new Record(); r3.setAttribute("F1", "Test5"); r3.setAttribute("F2", "Test6"); grid.setData(new Record[] { r1, r2, r3 });
I've implemented a first workaround and added a ClickHandler to the VLayout. However, this only solves one part of the problem: The cell gets indeed selected, but obviously it doesn't get the (keyboard) focus. When you use the arrow keys, the navigation starts from the previously selected cell in F1 or F2 (if any cell has been selected before), which is really odd behavior.
Code:
layout.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { CellSelection cs = getCellSelection(); cs.selectSingleCell(getRecordIndex(record), colNum); } });
Do you have any other suggestions?
I would really appreciate your help in this matter. Thank you!
Smart GWT version:
v9.0p_2013-08-29/PowerEdition Deployment (built 2013-08-29)
Browsers:
Firefox 23.0.1
IE 9
Comment