Question

I have a grid, that has a store, which gets json data from a url. When I m changing the values in the store, I am reassigning the store to the grid. I have observed in the developer Tools that the grid is being assigned the new store. Even when I check it with, dijit.byId(), I m able to see the updated store. But, the display still remains the same. Below is the code, I have used to reload my grid.

    function refreshGridWithNewStore() {
        require([
        "dojox/grid/DataGrid",
        "dojo/store/Memory",
        "dojo/data/ObjectStore",
        "dojo/request",
        "dojo/domReady!"
    ],
    function (DataGrid, Memory, ObjectStore, request) {
        request.get("DataPage.aspx", {
            handleAs: "json"
        }).then(function (data) {
            grid.store.close();
            dataStore = new ObjectStore({ objectstore: new Memory({ data: data }) });
            grid.setStore(dataStore);                
            grid.render();
        });
    });
    }
Was it helpful?

Solution

Try changing the property objectstore to objectStore. As far as I know it's case sensitive, so objectstore is not the same as objectStore. Even the grid.render() is not necessary I think.

So your code would become:

dataStore = new ObjectStore({ objectStore: new Memory({ data: data }) });

I also made an example JSFiddle.

If that doesn't work, try using the startup() function. Some widgets need to be completely rebuilt after changing the store and using something like the code below might help in your situation.

grid.startup();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top