PDA

View Full Version : Add 1 row every n seconds to grid



avalverde
20 Jul 2009, 11:26 AM
Hi everybody, I trying to migrate a flash application to extjs, this is what my flash app does, it basically request to a webservice app data every 5 seconds and add the new data to the top of a grid, it use flashremoting so everything goes through classes.

Now I know we can get external data using urls, I already have some php files that response xml data, then I will need something like this:

1) The firts time the grid will request every 5 seconds to the php file for a new record on the database who has the timestamp higher than the hour when we opened the grid, some request like the following url: getdata.php?time=20090720_15:24:24

2) When we get data that fits filter above, the grid will keeps requesting data to the php file every 5 seconds but with the last record id, ,url: getdata.php?lastid=200944564 .

3) Every request can response more than 1 record and all the new records will be adding at the top of the grid.

Thanks

steffenk
20 Jul 2009, 1:19 PM
Use the TaskMgr to make a periodic call like


this.loadingTask = {
run: function(){
// do your request here and add data to the store
},
interval: 5000,
scope: this
};

Ext.TaskMgr.start(this.loadingTask);

avalverde
20 Jul 2009, 1:34 PM
How do I add the data @ the top of the grid?

Thanks

MD
20 Jul 2009, 8:52 PM
You add the new records to the store that is associated with the grid, then call a refresh on the gridview.

The API docs are there to help you know ;) http://extjs.com/deploy/ext-3.0.0/docs/

mystix
20 Jul 2009, 10:07 PM
You add the new records to the store that is associated with the grid, then call a refresh on the gridview.

The API docs are there to help you know ;) http://extjs.com/deploy/ext-3.0.0/docs/

you shouldn't have to manually refresh the GridView if you're adding new Records to the grid's Store (or updating/removing existing Records even) -- this is already handled automatically for you.