3 Replies Latest reply on Oct 30, 2007 7:02 AM by paulfeuer

    DataGrid scroll positions resetting with dynamic dataprovider

    paulfeuer Level 1
      Hi - I have a DataGrid that is backed by an ArrayCollection that is fairly dynamic. Before doing my updates, i disable autoupdating, and though my size is typically fixed at 100 items, sometimes those items will be replaced. My problem is that a user who has scrolled down the visible grid, will lose their scroll position when i replace items. If i'm just doing updates on the existing objects, it's fine, but the replace is causing the scrolls (both horizontal and vertical) to reset. I've tried to isolate where this is happening (whether set verticalScrollPosition or on the bookmark) and i can't quite find it.

      Anyone know how i can prevent this behavior? I've tried capturing the scoll position before i begin my updates, and then setting it back when finished, but it doesn't work.

      Thanks.

      ./paul
        • 1. Re: DataGrid scroll positions resetting with dynamic dataprovider
          ntsiii Level 3
          "...I've tried capturing the scoll position before i begin my updates, and then setting it back when finished..."

          This is the correct approach.

          Try it again, but this time, after the update to the dataProvider, use callLater() to call the function that restores the scroll position.

          You often need to use callLater() after updating a dataProvider, or assigning a dp to a control in order to give the control a chance to be rendered before performing visually oriented actions on the control.

          Tracy
          • 2. Re: DataGrid scroll positions resetting with dynamic dataprovider
            paulfeuer Level 1
            Interesting. makes sense. While this does indeed succeed in scrolling the grid to the correct position, there is quite a noticeable delay - the scroll will be back at the top of the list for almost one second ("one one thou-") before rescrolling down to the captured position. wish there was a "callSoonerRatherThanLater" type of function ;)
            • 3. Re: DataGrid scroll positions resetting with dynamic dataprovider
              paulfeuer Level 1
              Actually, I spoke too soon. I had a number of things I was trying. And when i tried to clean up the other things that I believed were extraneous (including an override of makeColumnsAndRows), the vertical scroll resetting stopped working. I've spent about 90 minutes trying to get back to where I was (wish the builder was in IntelliJ!).

              When it was working, I also tried to add horizontal scroll capturing, and that didn't seem work either. I have 34 columns, the first one is locked. When I captured my position, I saw it was 11. Then i performed the update, and callLater my resetScroll position. The first column i saw after the locked column is correct. However, the scroll bar itself is fully left. On the next update I captured a horizontal scroll of zero.

              ./paul