2011-08-26 90 views
0

我有一個EXT窗體,它打開一個包含GridPanel的窗口,其中每次提交表單時都需要更新數據存儲區。網格顯示從客戶端計算機上傳的文件列表。所有這些工作正常,直到我關閉窗口並選擇一組不同的文件。我遇到的問題是當包含網格的窗口關閉然後重新打開時,它正在顯示先前加載的第一組文件,而不是從窗體提交的新文件列表。希望這是有道理的。我試過grid.getView()。refresh()但不更新網格。我試過grid.getView()。refresh(),但不更新網格。以下是我的窗口,窗體,網格和JSON商店的代碼。如果有人看到這個,我一定會欣賞一些建議。 (道歉的代碼格式...有很多的麻煩它是可讀的這個文本框)當窗口重新打開時EXTJS GridPanel內部窗口沒有從存儲中加載更新的數據

//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); 
} 

回答

2

從我的理解,你不需要只refresh的觀點,也reload的根據設定不同的文件,你選擇的store ..

所以,與其做

grid.getView().refresh()使用grid.getStore().reload([new-options-if-required]);。這將根據傳遞的選項,如果有的話重裝店面,或重新加載根據商店到最後的加載選項。