Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Selecting specific row by row number
Selecting specific row by row number [message #1397877] Thu, 10 July 2014 09:31 Go to next message
Alexander Klatt is currently offline Alexander KlattFriend
Messages: 59
Registered: April 2014
Member
Hi,
I would like to select a certain row by its number. I tried the approach with:
natTable.doCommand(new SelectRowsCommand(natTable, 1, rowNumber, false, false));

But this selects the row from the currently visible rows (so eg. scrolled to row 500 -> select row 2 -> selection is now 502 instead of 2)
Is there any better approach to do this?
Re: Selecting specific row by row number [message #1397902 is a reply to message #1397877] Thu, 10 July 2014 10:17 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
A coordinate in NatTable is a combination of layer and position. Your example will create the coordinate for NatTable row position 2. As you have a viewport, the position is related to the current scrolling position.

Try

natTable.doCommand(new SelectRowsCommand(dataLayer, 0, rowNumber, false, false));


which will use a DataLayer coordinate.

If that doesn't work, try

selectionLayer.doCommand(new SelectRowsCommand(selectionLayer, 0, rowNumber, false, false));


Although from my understanding the first one should work.
Re: Selecting specific row by row number [message #1397926 is a reply to message #1397902] Thu, 10 July 2014 10:58 Go to previous messageGo to next message
Alexander Klatt is currently offline Alexander KlattFriend
Messages: 59
Registered: April 2014
Member
Thank you. The selectionLayer way works!

Although to the the same issue: I create a DefaultGridLayer and save that as a variable. Then I access the selection layer via gridLayer.getBodyLayer().getSelectionLayer() is that a strange way to do this or is this fine Very Happy?
Re: Selecting specific row by row number [message #1397929 is a reply to message #1397926] Thu, 10 July 2014 11:03 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
As long as we do not have dependency injection, I don't see another way.
Re: Selecting specific row by row number [message #1397966 is a reply to message #1397929] Thu, 10 July 2014 12:08 Go to previous message
Alexander Klatt is currently offline Alexander KlattFriend
Messages: 59
Registered: April 2014
Member
Okay, thanks! That's good to know.
Previous Topic:How to set text on Group by region
Next Topic:Sorting and Indices
Goto Forum:
  


Current Time: Wed Apr 24 23:37:07 GMT 2024

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

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

Back to the top