2011-06-16 112 views
1

因此,當存儲數據發生更改時,我試圖刷新Datagrid。刷新Dojo Datagrid

//Store for my datagrid 
var myStore= new dojo.data.ItemFileWriteStore({ url : '/my/store.html', clearOnClose:true, urlPreventCache:true }); 

當我做一個AJAX調用保存/更新數據網格,在Ajax調用回調函數,我稱之爲:

function myCallBack() 
{ 
myStore.close(); 
Alert("Data Saved Successfully"); 
} 

,在網格更新記錄的功能,調用myStore.save()就在退出之前。 此方案能正常工作在Firefox,但電網沒有在IE8刷新

任何指針或幫助深表感謝。

回答

2

好的,我找到了解決方案。首先,您需要關閉這家商店在網格:

myGrid.myStore.close(); 

然後設定儲存回用新數據網格:

myGrid.setStore(newStoreData); 

欲瞭解更多信息,請this

+0

不是爲我工作在IE8 – 2013-06-27 17:13:32

2

你也可以重置查詢以便再次執行。按照爲了設定該頁面的教程:http://dojotoolkit.org/documentation/tutorials/1.7/store_driven_grid/

在示例數據網格與存儲在存儲器中:

require(["dojox/grid/DataGrid", "dojo/data/ObjectStore", "dojo/store/Memory", "dojo/domReady!"], 

      function (DataGrid, ObjectStore, Memory) { 
      var formsList = [ 
       {id:1, name:"Jim", department:"accounting"}, 
       {id:2, name:"Rosenblumentalovitsch", department:"engineering"}, 
       {id:3, name:"Mike", department:"sales"}, 
       {id:4, name:"John", department:"sales"} 
      ]; 
      formStore = new Memory({data:formsList, idProperty:"id"}); 

      formGrid = new DataGrid({ 
       store:dataStore = ObjectStore({objectStore:formStore}), 
       query: {id: "*"} , 
       structure:[ 
        { name:"Form", field:"name", width:"100%" } 
       ] 
      }, "grid"); 
      formGrid.startup(); 
      }); 

增加了formStore中的元素的數據網格不會自動刷新時。下面是刷新的addForm功能:()

function addForm(evt) { 
    // set the properties for the new item: 
    var myNewItem = {id:5, name:"Jim 2", department:"accounting"}; 
    // Insert the new item into the store: 
    formStore.add(myNewItem); 
    formGrid.setQuery({id: "*"}); //this row executes the query again, thus refreshing the data grid 
} 
+0

你也可以這樣做formGrid.sort - 它也要求_refresh對電網。 – unludo 2012-06-12 20:18:29