How to refresh dojo gridx after the memory store has changed?

Danubian Sailor picture Danubian Sailor · Jul 3, 2013 · Viewed 9.7k times · Source

I'm using dojo 1.9 and gridx. The grid is initialized with memory store. But when the data have changed, I update the store but I see no changes applied to grid. It has no refresh() method (like dgrid). However, I've found the following sequence:

            grid.model.clearCache();
            grid.model.setStore(store)
            grid.body.refresh()

It causes the grid to display Loading... message, but nothing more happens.

However, paginator shows the correct number of pages, only the grid container is not rendering the rows.

The example with filters /gridx/tests/test_grid_filter.html from the gridx sources has the same problem: Loading... message, but no data.

So the first question is, is it a bug? If it's not a bug, how should I then tell the grid that the data has changed and it should be reloaded?

Answer

Danubian Sailor picture Danubian Sailor · Oct 17, 2013

My previous answer works, and judging from upvotes it was useful for other, but I've found much simpler way, that doesn't require to re-create the store:

grid.model.clearCache();
grid.model.store.setData(items)
grid.body.refresh()

The key operations is clearing the cache, setting new items, and forcing the refresh of browser.

The confusing thing is, that GridX has 'store' property, but it is not the object that is used to present the data. The actual object is the store that is set on the model, so this is the object you need to modify.