UpdateDataCommand + ViewportLayer [message #1843536] |
Thu, 05 August 2021 01:32  |
Eclipse User |
|
|
|
Hello,
In one of my previous posts (https://www.eclipse.org/forums/index.php/t/1107637/), you helped me figuring out what I was doing wrong in regards to implementing the data tracking changes and using the UpdateDataCommand did the trick.
What I found out now is that the UpdateDataCommand doesn't work properly when the column that I'm trying to update is not fitting/is not visible in the screen.
Based on some debugging in the code that calculates the coordinates and so on, my assumption is that this happens because when it comes to the ViewportLayer, the columnCount will be always the number of the columns visible.
Is there a way in which I should reconfigure the layers or am I missing something?
Attached the example updated.
Thank you!
Kind Regards,
Alexandra
|
|
|
Re: UpdateDataCommand + ViewportLayer [message #1843540 is a reply to message #1843536] |
Thu, 05 August 2021 03:53   |
Eclipse User |
|
|
|
Hi,
the thing you are missing is the concept of the virtual table added by the ViewportLayer. :)
A viewport means that you only process what is visible. This is especially important for huge tables and the rendering. Without the ViewportLayer the renderers would paint and process everything, even if it is not visible.
That said, if the column you want to modify is not visible, the ViewportLayer would drop the command and would not further process it, as it is not visible. As the NatTable is the top-most layer above the ViewportLayer, you can't trigger an UpdateDataCommand on a command that is not visible.
Another reason for this is the concept of index-position-transformation. The parameters for the UpdateDataCommand are positions. This means they are relative to the layer on which the command is executed. This might not be the index of the row or column on the bottom-most layer.
The issue in your example is that you want to trigger an UpdateDataCommand on a NatTable with the assumption that column 5 means the fifth column in the DataLayer. But using the ViewportLayer in a scrolled or resized state where the column 5 is not visible, will fail. In short, you want to use the column position as a column index.
So you need to shift your execution on the SelectionLayer for example, so the update is even executed if the column is not visible.
SelectionLayer selectionLayer = bodyLayerStack.getSelectionLayer();
int rowPosition = MenuItemProviders.getNatEventData(event).getRowPosition();
int selectionLayerRowPosition = LayerUtil.convertRowPosition(natTable, rowPosition, selectionLayer);
selectionLayer.doCommand(new UpdateDataCommand(
selectionLayer,
4,
selectionLayerRowPosition,
Boolean.TRUE));
natTable.refresh(false);
The refresh() call is by the way necessary for the same reason. By design it would not be necessary to re-render the table again if something out of the visible area has changed.
Hope that helps.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03494 seconds