Alexander
Alexander

Reputation: 269

How to clear a dojox.grid.DataGrid to Update the grid

I have a grid filled with ajax, the user enters new data and call back to the ajax method that fills the grid, the problem I have is that the grid are duplicate data, I have tried before upgrading the grid to fill with a empty strore but does not work,

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

// This is part of code in 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();

I hope someone can help me, THX.

Upvotes: 0

Views: 3757

Answers (2)

Alexandra
Alexandra

Reputation: 11

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

Upvotes: 1

Alex.Bullard
Alex.Bullard

Reputation: 5563

Try using nuevasColecciones.close() instead of nuevasColecciones.fetch() and provide a url param instead of the data param. That should refresh the data in the store, and as long as you have already posted the new data, you will get all of the objects back

Upvotes: 0

Related Questions