Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to restore a column selection(after hiding a row (via context menu or via api))
How to restore a column selection [message #1802996] Wed, 20 February 2019 13:27 Go to next message
Hilger Steenblock is currently offline Hilger SteenblockFriend
Messages: 16
Registered: June 2016
Junior Member
After hiding a row (via context menu or via api) the column selection is lost. I have tried to set the column afterwards manually via the API but this doesn't have the expected effect.

The behavior is reproducible with demo example _5072_RowHideShowExample
1. Select first column
2. right click on the first step header and hide the step
-> the selection is removed
-> hiding the last row doesn't clear the column selection.

My code snippet to restore the column selection
int colPosition = selectionLayer.getColumnPositionByIndex(column);
SelectColumnCommand command = new SelectColumnCommand(selectionLayer, colPosition, 0, false, true);
natTable.doCommand(command);

Re: How to restore a column selection [message #1803002 is a reply to message #1802996] Wed, 20 February 2019 14:30 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2682
Registered: July 2012
Senior Member
The removal of the selection is done because removing a row or column is a structural change, and structural changes by default clear any selection to avoid inconsistent states. For the last row this does not happen because the event is consumed and not fired to the top. At least as far as I can remember.

Your code to set the selection again is probably because you are to fast. If you do this in an ILayerListener at NatTable level once a CellSelectionEvent is received and the state is clear, it should work in theory.

For such cases where the selection should be persisted regardless of structural changes, the PreserveSelectionModel exists. But the performance for huge data sets is not that good because the selection needs to be re-calculated. And that could take quite a while if the dataset is huge.
Re: How to restore a column selection [message #1803425 is a reply to message #1803002] Thu, 28 February 2019 14:50 Go to previous messageGo to next message
Hilger Steenblock is currently offline Hilger SteenblockFriend
Messages: 16
Registered: June 2016
Junior Member
I have delayed the mentioned selection calls for some milliseconds and that solves the issue in my application.
Re: How to restore a column selection [message #1805142 is a reply to message #1803425] Mon, 08 April 2019 09:56 Go to previous message
Hilger Steenblock is currently offline Hilger SteenblockFriend
Messages: 16
Registered: June 2016
Junior Member
I have used following snippet:

       PaintListener pl = new PaintListener() {

            @Override
            public void paintControl(PaintEvent e) {
                // add here your selection code
                natTable.removePaintListener(this);
            }
        };
        natTable.addPaintListener(pl);
        natTable.refresh();
Previous Topic:Spanned Cells show not always the data of the first column
Next Topic:How to reorder multiple columns
Goto Forum:
  


Current Time: Mon May 20 07:21:02 GMT 2019

Powered by FUDForum. Page generated in 0.02171 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top