当窗口重新打开时,窗口内的EXTJS GridPanel不会从存储中加载更新的数据

时间:2011-08-26 19:39:35

标签: extjs

我有一个EXT表单,打开一个包含GridPanel的窗口,每次提交表单时数据存储都需要更新。网格显示从客户端计算机上载的文件列表。所有这一切都正常,直到我关闭窗口并选择一组不同的文件。我遇到的问题是当包含网格的窗口关闭然后重新打开时,它显示先前加载的第一组文件而不是从表单提交的新文件列表。希望这是有道理的。

我已经尝试过grid.getView()。refresh()但是没有更新网格。下面是我的窗口,表单,网格和JSON存储的代码。如果有人见过这个,我肯定会欣赏一些建议。 (为代码格式化道歉......在这个文本框中可以读取它有很多麻烦)

//window that holds grid   
SPST.window.POGCheckInWindow = Ext.extend(SPST.window.WindowBaseCls, {
    id: 'POGCheckInWindow'  
    ,initComponent:function() {  
    var config = {  
            title: 'Check In POG Files'
            ,width      : 1000  
            ,height     : 500  
            ,maximizable: false  
            ,shadow : false  
            ,closeable: true  
            ,closeAction: 'hide'  
       ,items: [{  
       xtype   : 'checkin_results_grid'  
    ,id     : 'POGCheckInGrid'  
    ,height : 450  
             ,width  : 990  
        ,frame  : true }   
]};  
Ext.apply(this, Ext.apply(this.initialConfig, config));   
    SPST.window.POGCheckInWindow.superclass.initComponent.apply(this, arguments);  
    }    
});
Ext.reg('pog_checkin_window',SPST.window.POGCheckInWindow);  



//function to submit the form, load the store and open the window containing the gridpanel  
checkin:function() {  
    if (this.getForm().isValid()){  
        this.getForm().submit({  
        url: 'components/POG.cfc?method=uploadPOGTemp' + '&dsn=' + SPST_dsn  
        ,method: 'GET'  
        ,scope:this  
        ,success: function(form, action){  
var chkinwin = new SPST.window.POGCheckInWindow();  

Ext.getCmp('POGCheckInGrid').getStore().load({params:  {dsn: SPST_dsn, 
pogfiles: action.result.pogfiles, project_id: action.result.project_id}  
,callback: function(rec, options, success){      
Ext.getCmp('POGCheckInGrid').getView().refresh();  
            }  
            });  
            chkinwin.show();  
        }
        ,failure:this.showError  
        ,waitMsg:'Uploading files...'
        });  
    }  
}  



// create the data store for grid
    var chkstore = new Ext.data.JsonStore({  
    // JsonReader configuration  
    root           : 'jsonlist' 
    ,fields        : chkfields  
    ,id    : 'chkstoreid'  
    // JsonStore configuration  
    ,autoLoad       : true  
    ,remoteSort     : true  
    ,autoDestroy: true
    ,sortInfo: {  
             field: 'POGNAME',  
             direction: 'ASC'  
        }
    ,url   : 'components/POG.cfc?method=getPOGTempFiles' + '&dsn=' + SPST_dsn  

});


//grid that loads inside ext window  
SPST.grid.POGCheckInGrid = Ext.extend(SPST.grid.GridPanelBaseCls, {  
view: new Ext.grid.GridView({  
    getRowClass: function(rec, idx, rowPrms, ds)  
    {  
    return rec.data.VERSION_DSC === 'INVALID VERSION#' ? 'invalid-cls' : '';  
    }  
}),  
initComponent : function() {    
var config = {  
    colModel   : chkcolModel  
    ,selModel   : chkselModel  
    ,store      : chkstore  
    ,autoDestroy: true  
    ,xtype      : 'checkin_results_grid'  
    ,buttons: [  
        {  
        text: 'Upload'  
        ,handler: this.loadPOGCheckin  
        ,scope  : this  
        },  
        {  
        text: 'Cancel'  
        ,handler: this.checkinwindowclose  
        ,scope  : this  
        }
]  
}  
Ext.apply(this, Ext.apply(this.initialConfig, config));  
SPST.grid.POGCheckInGrid.superclass.initComponent.apply(this, arguments);  
}  

,onRender  : function() {  
this.getBottomToolbar().bindStore(chkstore);  
SPST.grid.POGCheckInGrid.superclass.onRender.apply(this, arguments);  
}

1 个答案:

答案 0 :(得分:2)

根据我的理解,您不需要refresh视图,而且reload根据您选择的不同文件集store

所以,而不是做

grid.getView().refresh()使用grid.getStore().reload([new-options-if-required]); ..这将根据传递的选项重新加载商店(如果有),或根据上次加载选项重新加载商店。

相关问题