View Full Version : Problem keeping scroll position after refresh

16 Nov 2012, 4:06 PM
Oops! I posted on general forum and I meant to post it here.

I have a Ext JS 3.4.0 code that shows 2 grids and it refreshes the datastore of the grids every 10 seconds. The refresh code cannot reset the scroll position and cannot remove the selected row of the grid.

My code is working on my local machine without a problem, but when I move it to the client's machine, it works for around 30 min and it then resets the scroll position back to {top:0, left:0}

I'm running the code from within eclipse, everything is the same, just one machine is MAC OS/X in one network and another machine is Windows in another network. Same browser, FF.

Any ideas of what can be resetting the scroll position?

19 Nov 2012, 2:59 AM
We would need to see how you're currently achieving the ability to maintain scroll position between store reloads.

One of the best solutions is explained here:

19 Nov 2012, 3:21 PM
I was in fact using something a lot more complex, saving the scroll position before load and restoring it with a delay after load, because Ext JS would reset the scroll position with a delay after the load event was triggered.

So I tried the approach you suggested and I'm testing it now to see if it works.

19 Nov 2012, 4:11 PM
I tried the approach you mentioned, of overriding the gridView adding the holdPosition flag and testing it on the onLoad code.

I'm having a strange behavior on the code. I have two tabs and a grid on each tab.

My code enables automatic data refreshing only on the active tab. I'm listening to activate and deactivate events for that.

Activate starts Refreshing and deactivate stops Refreshing

On the grid data store itself, because I have to also keep the row selected after refresh, I'm listening to beforeLoad and load events. BeforeLoad I save the selected row and on load I restore the selected row.

Is there a better way to keep the selected row after data store reload()? I'm using lock and unlock on the selection model, but it is not working. It keeps the row selected, but the visual indication (the different background) goes away. The effect is bad, if the user clicks on that selected row again, nothing happens because the selection model thinks it is already selected. If the user clicks on another row, it sects it properly, changing its background. That's why I'm saving the selected row on beforeLoad and restoring it on load events.


19 Nov 2012, 9:29 PM
It seems that the scroll position from previous session is being recorded somewhere, because when I refresh the page (refresh on the browser), it shows my new grid with the scroll position that is was in the previous session. How can I make Ext JS forget the scroll position between sessions, on the onReady function?