I'd use Ext.data.Store instead. Then all you have to do is reload() the Store in your setInterval function... Example:
Code:
var testDataStore = new Ext.data.Store({
id: "testDataStore",
autoLoad: true,
proxy: new Ext.data.HttpProxy({
url: "script.php",
method: "POST"
}),
baseParams: {task: "GET-STUFF"},//optional, depending on your remote script
reader: new Ext.data.JsonReader({
root: "results",
totalProperty: "total",
id: "id"
},[
{name: "test", type: "int", mapping: "test"},
{name: "test1", type: "string", mapping: "test1"},
{name: "test2", type: "string", mapping: "test2"}
])
});
var testColumnModel = new Ext.grid.ColumnModel(
[{
header: "Test",
dataIndex: "test",
width: 100
},{
header: "Test 1",
dataIndex: "test1",
width: 100
},{
header: "Test 2",
dataIndex: "test2",
width: 100
}]
);
var testGrid = new Ext.grid.GridPanel({
id: "testGrid",
store: testDataStore,
cm: testColumnModel,
selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
viewConfig: {
forceFit: true
}
});
testDataStore.load(); //load for the first time
testDataStore.reload(); //reload data will also refresh the grid automatically
Your script needs to return JSON.... example:
({'total':'1','results':[{"test":"The orig test","test1":"This is the 1st Test","test2":"This is the 2nd test"}]})