2011-08-09 22 views
0

我有一個網格用ajax填充,用戶輸入新數據並回調到填充網格的ajax方法,我遇到的問題是網格是重複數據,我已經升級前柵格試圖填補一個空白strore但不工作,如何清除dojox.grid.DataGrid來更新網格

var gridColeccion = dijit.byId("colectionGrid"); 
var dummy = {items: []}; 
var newEventStoreColeccion = new dojo.data.ItemFileReadStore({clearOnClose:true,data:dummy}); 
newEventStoreColeccion.fetch(); 
gridColeccion.setStore(newEventStoreColeccion); 
gridColeccion._refresh(); 


    folderConsult(token); // This metod fill the grid again 

//這是在folderConsult代碼的一部分;

var datosColeccion = { 
       items: itemsColeccion 
     }; 

var gridColecccion = dijit.byId("colectionGrid"); 
nuevasColecciones= new dojo.data.ItemFileReadStore({clearOnClose:true,data: datosColeccion}); 
nuevasColecciones.fetch(); 
gridColecccion.setStore(nuevasColecciones); 
gridColecccion._refresh(); 

我希望有人能幫助我,THX。

回答

0

嘗試使用nuevasColecciones.close()而不是nuevasColecciones.fetch()並提供url參數而不是data參數。這應該刷新商店中的數據,並且只要您已經發布了新數據,您就會獲得所有對象返回

1
while(grid.store._getItemsArray().length!=0) 
{ 
    grid.store.deleteItem(grid.store._getItemsArray()[0]); 
} 
grid.store.save();