2013-07-29 23 views
1

我在我的應用程序中使用帶有JSONrest存儲的OnDemandGrid。第一次,網格加載正常,如果我再次搜索其他數據,已經在網格中的數據與新數據重疊。有人告訴我如何重置或刷新OnDemandGrid?如何重置OnDemandGrid

這裏是我的代碼,

  function (request, Memory, OnDemandGrid,JsonRest) { 

      var jsonstore = new JsonRest({target: url,idProperty: "srno"}); 
      grid = new OnDemandGrid({ 
       store: jsonstore, 
       columns: Layout, 
       minRowsPerPage : 40, 
       maxRowsPerPage : 40, 
       keepScrollPosition : true, 
       loadingMessage: "Loading data...", 
       noDataMessage: "No results found." 
      }, "grid"); 
      grid.startup(); 

});

回答

0

下面是http://forums.arcgis.com/threads/39150-dojox.grid.DataGrid-how-to-clear-results

var newStore = new dojo.data.ItemFileReadStore({data: { identifier: "", items: []}}); 
var grid = dijit.byId("grid"); 
grid.setStore(newStore); 

}

帶到清除網格的結果爲例。

我們使用一個類似的案例刪除我們使用ItemFileReadStore:

var emptyStore = clearStore(); 
dijit.byId("selectGemarkung").store = emptyStore; 

希望這有助於。

更新1: 看看這個:delete item from a dojo.store.jsonrest

我認爲jsonstore.remove()將做到這一點。

關懷,Miriam

+0

使用jsonreststore,如何實現這一目標? – SSayee

+0

更新了我的答案 - 也許這是方法 – MiBrock

0

收集數據應設置爲空;否則刷新()不會工作。此外,收集數據不應指定空白商店對象dojo.data.ItemFileReadStore

grid.collection.setData(""); 
grid.refresh(); 

由於我們從OnDemandGrid中刪除集合內部dstore錯誤將在控制檯中記錄下面的js文件。

dstore/Trackable.js, 
dstore/Memory.js, 
dstore/Promised.js