Hybrid View

  1. #1
    Sencha Premium Member
    Join Date
    Jul 2011
    Posts
    119
    Vote Rating
    5
    john76543 is on a distinguished road

      0  

    Default preserveScrollOnRefresh problem, randomly going to top

    preserveScrollOnRefresh problem, randomly going to top


    When I insert a row at the end of my grid, preserveScrollOnRefresh: true makes the scroll position get preserved across the save (great!). But I'm experiencing a weird issue where the grid later scrolls to the top! It happens something like this:

    Insert a record, and save (position is preserved)
    Scroll up a bit and select a record
    Scroll back down to bottom
    Select bottom record
    Select bottom-1 record
    (bang, I'm suddenly at the top of my grid)

    Any ideas of a work around? All solutions I've seen rely on hooking load, but this issue happens much later, and is actually triggered by a row selection.

    Ext 4.1.1rc2

  2. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,080
    Vote Rating
    467
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      0  

    Default


    Do you have a small test case based on one of our online examples that we can use to test this?

    Scott.

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2011
    Posts
    119
    Vote Rating
    5
    john76543 is on a distinguished road

      0  

    Default


    No unfortunately not.. I'll try and build one.

    It seems related to the presence of a form in the top third of the page. With the form collapsed I don't see the bug.

  4. #4
    Sencha Premium Member
    Join Date
    Jul 2011
    Posts
    119
    Vote Rating
    5
    john76543 is on a distinguished road

      0  

    Default


    Still havent got a test case, but have dug into my code more. I had a form update triggered by scrolling, which calls BasicForm.markInvalid() and it turns out that triggered the scrolling problem!

    So my clunky workaround is to do:

    Code:
    var originalScrollPosition = MeldUI.maingrid.getEl().down('.x-grid-view').getScroll();
    Before I markInvalid, and this after:

    Code:
    var newPosition = MeldUI.maingrid.getEl().down('.x-grid-view').getScroll();
    if (newPosition.top < 5 && originalScrollPosition.top > 5)
        MeldUI.maingrid.getEl().down('.x-grid-view').scrollTo('top', originalScrollPosition.top, false);
    That solves the problem thankfully.
    Some other info: I'm using row editing. Inserted records go at the bottom. It only happens after the first insert, subsequent inserts are fine.

Thread Participants: 1

Tags for this Thread