Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ListGrid, Tab and scroll problem

    Hi,
    I have ListGrid (live grid) on a tab. Double click on a row changes tab's pane (listGrid.updateTab(...)). When I come back to the listgrid (listGrid.updateTab(...)) I want to see the last scroll position even if simple filter was enabled(now scroll always go to the beggining of grid after updateTab) How to resolve this problem? There is any handler on filter entered or workaround to get this handler?

    #2
    If I understood you correctly, I have attempted to perform something similar: I wanted to save the scroll position when I navigate away and restore it when I come back. The problem I ran into is that I found no way to get the current scroll position (to be clear: not selected row position). I tried the following methods:

    Code:
    getScrollBottom()
    getScrollTop()
    getDrawnRows()[0]
    getVisibleRows()[0]
    However, none of the methods work the way I expect them to. Regardless of the scroll position, they return "0" (or the case of getVisibleRows(), "-2").

    The exception is getDrawnRows()[0] which shows quite an interesting behaviour. If I scroll a couple lines down (e.g. 3, hiding the first 3 rows), getDrawnRows()[0] returns "0" as if nothing happened. However, if I move a lot more down the list, it returns >0. I took a couple of minutes to get a better understanding of what it does and have found out that it will return "0" if I've moved less than 11(?!) rows down, "11" if I've moved between 11 and 21 rows down, "22" if I've moved between 22 and...well, you get the picture.

    I've also noticed it returns "28" or "56" if I scroll down page by page.

    Anyone else ran into this?

    Comment


      #3
      Update: scrollToRow() seems to be non-trivial as well, although I've seen several reports of it working the way it's name suggests.

      Isomorphic mentioned that it might happen if the rows haven't been rendered yet so calling redraw() would help, but it doesn't seem to make a difference.

      My code can be described as follows (within an asynchronous event handler which is invoked when data for the grid arrives):

      Code:
      for each item
        dataSource.addData(new ItemRecord(...))
      grid.redraw()
      grid.scrollToRow(x)
      The scroll doesn't budge. My GWT knowledge is not yet up to the task of quickly providing a standalone minimal example reproducing the error.

      I have seen Isomorphic suggest scrolling on the dataArrived event, I am reluctant to do it that way because it would (as I understand it) call scrollToRow() after each record added and I just need to set the scroll when all of the data has been loaded.

      Comment


        #4
        Hi,

        I have the exactly same problem.

        It works with the following code

        Code:
        listGrid.addDataArrivedHandler(new DataArrivedHandler() {
                       public void onDataArrived(DataArrivedEvent dataArrivedEvent) {
                        DeferredCommand.addCommand(new Command() {
                            public void execute() {
                                listGrid.scrollToRow(selectedRows.get(0));
                            }
                        });
                    }
                });
        The list scrolls to the selected row. But now this code executes whenever data is arrived from the server and everytime, list scrolls to the same row. Unfortunately, there is no easy way to deregister the event as well.

        Does anyone knows right way to fix scrollToRow problem ?

        Comment


          #5
          addDataArrivedHandler(..) returns a HandlerRegistration instance. Call removeHandler() on it to unregister the listener.

          Comment

          Working...
          X