刚开始用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);
});

解决方案 »

  1.   

    在function OP(){}中试图              store.reload();
                  if(null != dataGrid) {
                        dataGrid.getStore().reload();
                         dataGrid.refresh();
                  }都不好使
      

  2.   

    function OP() 什么时候调用你的store 用的是本地的 开始的时候也没有将其赋值
      

  3.   

    有个点击响应,然后在function OP() 里面获得新的var result = data.result;
    然后我想把新的数据更新显示到grid上面