【问题标题】:How to clear a dojox.grid.DataGrid to Update the grid如何清除 dojox.grid.DataGrid 以更新网格
【发布时间】:2011-08-09 19:16:56
【问题描述】:

我有一个用ajax填充的网格,用户输入新数据并回调填充网格的ajax方法,我遇到的问题是网格是重复数据,我在升级网格之前尝试过填充一个空的 strore 但不起作用,

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。

【问题讨论】:

    标签: dojox.grid dojox.grid.datagrid dojo


    【解决方案1】:
    while(grid.store._getItemsArray().length!=0)
    {
       grid.store.deleteItem(grid.store._getItemsArray()[0]);
    }
    grid.store.save();
    

    【讨论】:

      【解决方案2】:

      尝试使用nuevasColecciones.close() 代替nuevasColecciones.fetch() 并提供url 参数而不是data 参数。这应该会刷新商店中的数据,只要您已经发布了新数据,您就会得到所有的对象

      【讨论】:

        猜你喜欢
        • 2011-11-23
        • 1970-01-01
        • 2015-07-02
        • 2011-05-12
        • 1970-01-01
        • 2012-10-19
        • 1970-01-01
        • 1970-01-01
        • 2019-03-20
        相关资源
        最近更新 更多