How To reset the OnDemandGrid

烈酒焚心 提交于 2019-12-11 05:42:15

问题


I am using OnDemandGrid with JSONrest store in my application.For the first time,the grid is loading fine , if i search again for other data,the data already in the Grid is getting overlapped with new data.Can someone tell me how to reset or refresh the OnDemandGrid?

Here is my code,

           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();

});


回答1:


Here's an Example taken from 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);

}

to clear the Results of a Grid.

We use an similar case to delete our used ItemFileReadStore:

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

Hope this helps.

UPDATE 1: Look at this : delete item from a dojo.store.jsonrest

I think jsonstore.remove() will do it.

Regards, Miriam




回答2:


Collection data should be set to null; else refresh() wont work. Also collection data should not be assigned blank store object dojo.data.ItemFileReadStore.

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

Since we are removing collection from OnDemandGrid internal dstore errors will be logged in console for below js files.

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


来源:https://stackoverflow.com/questions/17922363/how-to-reset-the-ondemandgrid

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!