View Full Version : Is it Possible to maintain the scroll Position of scroller in Infinite Grid Component

18 May 2012, 12:40 AM
I have applied

invalidateScrollerOnRefresh: false,
viewConfig: {
preserveScrollOnRefresh : true,

in my grid but had no success in preserving the scroll position, when ever the load is called


is called to pull new data the scroller goes back to top, am I doing some thing wrong please guide me, please guide , it will be well appreciated.

I can share my whole code too... if the above is less in clarification.


18 May 2012, 2:03 AM
generally in an infinite grid, invalidateScrollerOnRefresh: false works...
But in your case,it is not working....

try one of the following:-

viewConfig: {
onStoreLoad: Ext.emptyFn,

Ext.getCmp('Your Grid Name').invalidateScroller();

var scrollPosition = grid.getEl().down('.x-grid-view').getScroll();
//and then use the following

If nothing above works, Try to use saveScrollState() and restoreScrollState() http://docs.sencha.com/ext-js/4-0/#!/api/Ext.view.Table-method-saveScrollState

Still, not any success, provide your code for better understanding..

18 May 2012, 2:16 AM
Hi Sword,

thanx for responding
I found the emptyfn at some other thread too and tried but didnt worked this is how my view config looks right now :

viewConfig: {
columnLines : true,
loadingText : undefined,
loadMask : false,
preserveScrollOnRefresh : true,
onStoreLoad: Ext.emptyFn

then on other forum I found the 3rd sugestion of yours this is how I am trying to do it :
when the poller polls for new data for grid :

Ext.Direct.on('WarningStatusPoll', function(e){
// Load
var scrollPosition = logEntryGrid.getEl().down('.x-grid-view').getScroll();
console.info(scrollPosition.top); // scroller current position
function() {
console.info("just before appending : " + scrollPosition.top);
// logEntryGrid.getEl().down('.x-grid-view').scrollTo('top', scrollPosition, false); // no effect
// no effect either jumps back to top
scrollPosition = logEntryGrid.getEl().down('.x-grid-view').getScroll();
// above line position should come out to be the passed number but it comes to be zero '0'

the position which I get is usually a number like 98786 and then I set it using scrollTo and then I get the again to see if the value is really set but it prints 0 position and goes back to top. :s

18 May 2012, 2:35 AM
preserveScrollOnRefresh : true,


Ext.getCmp('Your Grid Name').invalidateScroller();

were of no help I think in this special polling case the get over
written by default values some where in libraries


var scrollPosition = logEntryGrid.getEl().down('.x-grid-view').getScroll();
logEntryGrid.getStore().load( function() {
logEntryGrid.getEl().down('.x-grid-view').scrollTo('top', scrollPosition.top, false);

Thanx for the Guidance Sword !!!!