PDA

View Full Version : Grid Auto Refresh



border9
3 Apr 2008, 10:48 AM
Im having issues locating a good resource, to make my grid auto refresh every 20 - 25 seconds. Does anyone have any good ideas pretaining to that issue?

Thanks

3 Apr 2008, 10:52 AM
You can use task manager to fire off a datastore reload. be aware that if a user has scrolled to a specific point, they get rolled back to zer0

border9
3 Apr 2008, 11:23 AM
The grid has paging on it, and the paging is set to 20 right now, is there a simple way to get the grid to auto refresh every 20 - 25 seconds all the time to make sure its up to date?

3 Apr 2008, 11:27 AM
http://extjs.com/deploy/dev/docs/?class=Ext.TaskMgr

border9
3 Apr 2008, 11:51 AM
ok i was playing with that a little, i got it to not throw any errors but it doesnt appear to be updating

refresh script

var mainquoterefresh = {
run: function(){
loadMask: true,
mainquoteStore
},
interval: 10000 //1 second
}
Ext.TaskMgr.start(mainquoterefresh);

Grid its Refreshing

var mainquoteStore = new Ext.data.Store({
storeId: 'mainquotes',
proxy: new Ext.data.HttpProxy({url:'php/JSONMQ.php'}),
reader: new Ext.data.JsonReader({
root: 'quotesmain',
remoteSort: true,
totalProperty: 'totalCount'
},
[
{name: 'select', type: 'float'},
{name: 'quote', type: 'string' , mapping: 'quote'},
{name: 'fname', type: 'string' , mapping: 'fname'},
{name: 'lname', type: 'string' , mapping: 'lname'},
{name: 'phonenum', type: 'string' , mapping: 'phonenum'},
{name: 'email', type: 'string' , mapping: 'email'},
{name: 'timerecieved', type: 'date', dateFormat: 'Y-m-d h:i:s a' , mapping: 'timerecieved'},
{name: 'customertype', type: 'string' , mapping: 'customertype'},
{name: 'websitesubmit', type: 'string' , mapping: 'websitesubmit'},
{name: 'delquote', type: 'float'}
]
)
});
mainquoteStore.setDefaultSort('quote', 'ASC');

Am i doint this wrong?

devnull
3 Apr 2008, 12:45 PM
theres a few extension that have been written for this as well.

3 Apr 2008, 12:47 PM
your function declaration is completely incorrect.
try:


var mainquoterefresh = {
run: function(){
mainquoteStore.load();
},
interval: 10000 //1 second
}
Ext.TaskMgr.start(mainquoterefresh);

chetan.akarte
9 Jun 2010, 5:50 AM
A TaskRunner [Ext.util.TaskRunner()] can be a good alternative to auto refresh a Grid. Derived from Class Ext.util; Class Ext.util.TaskRunner - Provides the ability to execute one or more arbitrary tasks in a multithreaded manner. Generally, you can use the singleton Ext.TaskMgr instead, but if needed, you can create separate instances of TaskRunner.


var task = {
run: function() {
mainquoteStore.load() // mainquoteStore is a variable... var mainquoteStore=new Ext.data.Store();
},
interval: 10000 //10 second
}
var runner = new Ext.util.TaskRunner();
runner.start(task);