Extjs stroe更新问题

fengling2001 2011-07-20 07:18:45
刚开始用Extjs,遇到更新问题,想通过相应函数function Op(),去更新对应的dataGrid,但是总是失败,代码如下:

var storeData = new Array();
var store;
var dataGrid;

function Op(){
var result = data.result;
for(var key = 0;key<result.length;key++){
storeData[key] = new Array();
for(var subkey = 0;subkey<result[key].length;subkey++) {
storeData[key][subkey] = result[key][subkey];
}
}

function DrawLine(points){
//TODO
}


Ext.onReady(function() {
store = new Ext.data.SimpleStore({data:storeData,autoLoad:true,fields:["id1","id2"]});
dataGrid = new Ext.grid.GridPanel({
width: 400,
height: 400,
border:false,
mode: 'local',
title:"表格",
store:store,
columns:[
{
xtype: 'gridcolumn',
dataIndex:'id1',
header: 'AA',
sortable: true,
width: 65
},
{
xtype: 'gridcolumn',
dataIndex: 'id2',
header: 'BB',
sortable: true,
width: 65,
align: 'right'
}
]
});
var viewPort = new Ext.Viewport({
layout: 'border',
items:[
new Ext.FormPanel({
region: 'west',
id:'searchform',
title:'查询',
collapsible: true,
height: 480,
width:200,
layout: 'absolute',
style:'font-size:12px',
items:[
{
xtype:'textfield',
width:100,
name:'s',
x:15,
y:5
},
{
xtype:'button',
text:'搜索',
x:130,
y:5,
handler:searchFunc
}
]
}),
new Ext.Panel({
region: 'east',
height: 480,
width:400,
collapsible: true,
layout: {
type: 'accordion',
animate: true
},
items:[dataGrid]
})
]
});
window.dataGrid = dataGrid;
window.dataStore = store;
DrawLine(points);
});

...全文
93 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
fengling2001 2011-07-20
  • 打赏
  • 举报
回复
有个点击响应,然后在function OP() 里面获得新的var result = data.result;
然后我想把新的数据更新显示到grid上面
zn85600301 2011-07-20
  • 打赏
  • 举报
回复
function OP() 什么时候调用

你的store 用的是本地的 开始的时候也没有将其赋值
fengling2001 2011-07-20
  • 打赏
  • 举报
回复
在function OP(){}中试图

store.reload();
if(null != dataGrid) {
dataGrid.getStore().reload();
dataGrid.refresh();
}

都不好使

81,091

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧