小弟我想实现的功能是通过无刷新自动更新表格的数据

我想实现的功能是通过无刷新自动更新表格的数据。
我想实现的功能是通过无刷新自动更新表格的数据。
如果后台数据变了,response.responseText可以改变,但是grid store里面的response.responseText没有改变 只有刷新后才能产生变化,请问各位兄弟姐妹,这是什么原因造成的?
代码如下:
function ajaxRequest() {
Ext.Ajax.request({
url : "http://127.0.0.1:8080/sample/jdbc_mysql.jsp",
method : 'GET',
success : function(response) {
// alert(response.responseText);
var grid = new Ext.grid.GridPanel({
height : 200,
width : 350,
enableColumnMove : false,

store : new Ext.data.JsonStore({
autoLoad : true,
data : Ext.util.JSON
.decode(response.responseText),
fields : ["id", "name", "password"]
}),
colModel : new Ext.grid.ColumnModel([{
header : "id",
align : "center",
menuDisabled : true
}, {
header : "姓名",
align : "center",
menuDisabled : true
}, {
header : "密码",
align : "center",
menuDisabled : true
}])
});

if (document.getElementById("stockgrid").innerHTML == "") {
grid.render('stockgrid');
/*
* grid.getView().refresh(); grid.getStore().load();
*/

}
}
});
}

Ext.onReady(function() {
ajaxRequest();
window.setInterval("ajaxRequest()", 3000);

});
你首先需要把store设为全局的,然后再onReady方法最后加入store.reload(),即:
Ext.onReady(function() {
ajaxRequest();
window.setInterval("ajaxRequest()", 3000);
store.reload();

});
1 楼 lei715880100 2010-07-03  
请问楼主,怎样把store设为全局的,能够给出具体的代码,谢谢了!