20 Jun 2012 8:56 AM #1
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.
20 Jun 2012 9:03 AM #2
Do you have a small test case based on one of our online examples that we can use to test this?
20 Jun 2012 9:06 AM #3
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.
21 Jun 2012 2:20 AM #4
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:
var originalScrollPosition = MeldUI.maingrid.getEl().down('.x-grid-view').getScroll();
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);
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.