Select a cell programmatically [message #1185885] |
Thu, 14 November 2013 10:30 |
Gunnar Krüger Messages: 3 Registered: November 2013 |
Junior Member |
|
|
Hi,
I am using the NatTable with GlazedList.
I want to select a cell programmatically.
The body layer stack:
SortedList<T> sortedList = new SortedList<T>(pEventList, null);
ListDataProvider<T> bodyDataProvider = new ListDataProvider<T>(sortedList, pColumnPropertyAccessor);
_bodyDataLayer = new DataLayer(bodyDataProvider, 200, 20);
GlazedListsEventLayer<T> glazedListsEventLayer = new GlazedListsEventLayer<T>(_bodyDataLayer, pEventList);
DefaultBodyLayerStack bodyLayerStack = new DefaultBodyLayerStack(glazedListsEventLayer);
The list contains about 100 entries. Now I want to select a cell.
cLOGGER.warn("select cell index column {0} row {1}", columnIndex, rowIndex);
SelectionLayer selectionLayer = ((DefaultBodyLayerStack)_layer.getBodyLayer()).getSelectionLayer();
int columnPosition = selectionLayer.getColumnPositionByIndex(columnIndex);
int rowPosition = selectionLayer.getRowPositionByIndex(rowIndex);
cLOGGER.warn("select cell position column {0} row {1}", columnPosition, rowPosition);
_natTable.doCommand(new SelectCellCommand(_layer.getBodyLayer(), columnPosition, rowPosition, false, false));
int testColumnPosition = ((DefaultBodyLayerStack)_layer.getBodyLayer()).getColumnPositionByIndex(columnIndex);
int testRowPosition = ((DefaultBodyLayerStack)_layer.getBodyLayer()).getRowPositionByIndex(rowIndex);
cLOGGER.warn("select cell test position column {0} row {1}", testColumnPosition, testRowPosition);
The selection is correct if the nattable shows the first entries. But if I have scrolled the nattable before the selected cell isn't correct.
E.g. a log:
select cell index column 0 row 1
select cell position column 0 row 1
select cell test position column 0 row -18
After scrolling the nattable shows only a part of the list. Obviously it selects the row with index 1 of this part, but I want to select the entry with the index 1 of the whole list. Row -18 might be the correct position but doesn't select any cell.
Any advice how to get the right row position? Or is there another possibility to select a cell.
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04322 seconds