六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 27|回复: 0

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

[复制链接]

升级  72.67%

126

主题

126

主题

126

主题

举人

Rank: 3Rank: 3

积分
418
 楼主| 发表于 2013-1-23 02:04:35 | 显示全部楼层 |阅读模式
我想实现的功能是通过无刷新自动更新表格的数据。
如果后台数据变了,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();

});
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表