Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
66
rated 0 times [  69] [ 3]  / answers: 1 / hits: 17601  / 12 Years ago, fri, october 26, 2012, 12:00:00

I'm using grid.Panel in Sencha ExtJs 4.0.2a and I reload a Json Store every 60 seconds.



I was wondering if there is a way to preserve the position of the scrollbar after a data load.

So that the user can continue to look at the records he was looking before the load..



I reload the data in the grid using a Task:



var task = {
run: function(){
Ext.getCmp(panelGridId).getStore().load({
//Callback function after loaded records
callback: function(records) {
//Hide grid if empty records
if (Ext.isEmpty(records)) {
Ext.getCmp(panelGridId).setVisible(false);
}
else {
if (Ext.getCmp(panelGridId).isHidden()) {
Ext.getCmp(panelGridId).setVisible(true);
Ext.getCmp(panelGridId).doComponentLayout();
}
}
}
});
},
interval: 60000 //60 seconds
};

Ext.TaskManager.start(task);


After the data load the scrollbar position is reset to the top..


Q: Is there a way to maintain the scrollbar position after the data load?



Thanks in advance!


More From » extjs4.1

 Answers
21

Try this bad boy to preserve scroll position on refresh:



http://docs-devel.sencha.com/extjs/4.2.1/#!/api/Ext.grid.View-cfg-preserveScrollOnRefresh



This works for me on my tree view.



viewConfig: {
preserveScrollOnRefresh: true
}

[#82332] Thursday, October 25, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
marisela

Total Points: 103
Total Questions: 105
Total Answers: 102

Location: Solomon Islands
Member since Fri, Oct 8, 2021
3 Years ago
;