Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Scrolling row into view programmatically(Problem with SelectRowsCommand)
Scrolling row into view programmatically [message #1696546] Wed, 27 May 2015 08:13 Go to next message
Marcin Junger is currently offline Marcin JungerFriend
Messages: 8
Registered: April 2015
Junior Member
Hi all,
I have an issue with the following command:
SelectRowsCommand(selectionLayer, 0, selectedRowPos, false, false)

The problem is that this command should scroll so that the row is visible, but it scrolls so that the row is "almost" visible - like two or three rows below bottom border of grid.

The background is that i have variable height of row in grid items - and I think this causes the issue. The selectedRowPos is 0-based index of row in data layer. With SelectRowsCommand, proper row is getting selected, but the scrollbar stops a bit to high...

I tried issuing the following command:
ShowRowInViewportCommand(viewportLayer, selectedRowPos)
but it behaves the same.

I tried adding + 4 into selectedRowPos in ShowRowInViewportCommand, and it seems to scroll my desired row into bottom of the grid... but if I want to see the last row - it does not help in that situation.

Any idea where I could look for some clues?
Is there a way to check if row is displayed? So I could check that and scroll a bit more if not?

Kind regards
Marcin
Re: Scrolling row into view programmatically [message #1696569 is a reply to message #1696546] Wed, 27 May 2015 10:13 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I think you should fire the command specifying the layer coordinates for the viewport

SelectRowsCommand(viewportLayer, 0, selectedRowPos, false, false)

Otherwise, which NatTable version do you use?

If it doesn't help and you are using the latest NatTable version, file a ticket.
Re: Scrolling row into view programmatically [message #1696598 is a reply to message #1696569] Wed, 27 May 2015 13:03 Go to previous messageGo to next message
Marcin Junger is currently offline Marcin JungerFriend
Messages: 8
Registered: April 2015
Junior Member
Tried with viewportlayer, the same effect.

I noticed also that this behavior iss differend depending on number of rows displayed. If I have 500 rows, selecting row programmatically almost always scrolls correctly, and selected row is the first from the top. If I have 50 records in my grid, selecting rows scrolls so that the selected row is rather near or below the bottom.

I am on org.eclipse.nebula.widgets.nattable.core.source_1.3.0.201503261201.jar.

If you need, I'll try to compile basic example. Maybe (hopefully) it will work in basic example and I will be able to find issue in my code....

Cheers
Marcin
Re: Scrolling row into view programmatically [message #1696609 is a reply to message #1696598] Wed, 27 May 2015 13:29 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
I currently don't have the time to look into this. If you think it is a bug, file a ticket and I will look into this as soon as I have time for it. Or look into it yourself and provide a fix. I'm not sure what is causing this behavior and how to reproduce it. The method for moving a row into the viewport is in the ViewportLayer.

For the scroll position the only thing I can think of is that it is not possible to scroll further downwards, since there are not enough rows. But I don't know. Maybe it is a bug and can also be seen with the search functionality.
Re: Scrolling row into view programmatically [message #1696720 is a reply to message #1696609] Thu, 28 May 2015 08:24 Go to previous messageGo to next message
Marcin Junger is currently offline Marcin JungerFriend
Messages: 8
Registered: April 2015
Junior Member
Right, so I have prepared simplistic lorem ipsum example. Dirk, maybe you will have some clues: the problem is if I select row near the end of data. The problem grows when in method getDataValue of IDataProvider i add a delay that simulates getting data from something more than array.

Ifthe delay 0, then 9 out of 10 requests to select row 97 out of 99 works fine. If delay is 10ms, almost all requests select the row fail - row is selected but below bottom border of grid and I need to scroll a bit.

Any hints?

I will try to find a cause of that, but not have much time this week.
  • Attachment: TestScroll.java
    (Size: 4.46KB, Downloaded 251 times)
  • Attachment: data.txt
    (Size: 18.83KB, Downloaded 222 times)
Re: Scrolling row into view programmatically [message #1773125 is a reply to message #1696720] Thu, 21 September 2017 22:29 Go to previous messageGo to next message
Shwetha Venkatesh is currently offline Shwetha VenkateshFriend
Messages: 15
Registered: March 2016
Junior Member
Facing the same issue and I tried to use the below snippet
natTable.doCommand(new ShowRowInViewportCommand(natTable.getBodyLayer().getViewportLayer(), rowPosition+delta));

It works if I set the delta value to rowPosition+ 10. However, if the current scroll is at the bottom of the table, it doesnot scroll upto the row, it needs an extra scroll to see the selection. Logically I need to do rowPosition-10 to get the scroll up to the right location.

So, we need to find the scroll position is at end of table or beginning of table and then set the rowPOsition + 10 or rowPOsition -10 accordingly.
Is there a way to find the current scroll position??

I know this is hack, appreciate if anyone has solved this issue could post the answer.

Thank you.
Re: Scrolling row into view programmatically [message #1773126 is a reply to message #1696720] Thu, 21 September 2017 22:30 Go to previous messageGo to next message
Shwetha Venkatesh is currently offline Shwetha VenkateshFriend
Messages: 15
Registered: March 2016
Junior Member
Facing the same issue and I tried to use the below snippet
natTable.doCommand(new ShowRowInViewportCommand(natTable.getBodyLayer().getViewportLayer(), rowPosition+delta));

It works if I set the delta value to rowPosition+ 10. However, if the current scroll is at the bottom of the table, it doesnot scroll upto the row, it needs an extra scroll to see the selection. Logically I need to do rowPosition-10 to get the scroll up to the right location.

So, we need to find the scroll position is at end of table or beginning of table and then set the rowPOsition + 10 or rowPOsition -10 accordingly.
Is there a way to find the current scroll position??

I know this is hack, appreciate if anyone has solved this issue could post the answer.

Thank you.
Re: Scrolling row into view programmatically [message #1773141 is a reply to message #1773126] Fri, 22 September 2017 07:49 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
As I don't like to answer the same question in multiple channels and you asked on Stackoverflow, find the answer here: https://stackoverflow.com/questions/46354237/scroll-nattable-programmatically-to-the-selected-row
Previous Topic:Possible bug in NatCombo using multiselect with easy fix
Next Topic:GroupBySummary Update Parent Summary value
Goto Forum:
  


Current Time: Thu Apr 25 06:11:48 GMT 2024

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

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

Back to the top