harris
harris

Reputation: 39

Dojo grid goes hidden when grid is refreshed

I am refreshing dojox.grid.EnhancedGrid using dojo.data.ItemFileWriteStore per second. I have a dijit.layout.TabContainer where EnhancedGrid is present in one of the tab. When I switched the tab and come back to grid tab, the whole grid disappears.

What can be the solution?

var store = new dojo.data.ItemFileWriteStore({
    url: '',
    data: result,
    urlPreventCache: false
});
grid.setStore(store);

Upvotes: 0

Views: 393

Answers (1)

Math is Hard
Math is Hard

Reputation: 942

I'm not sure about using EnhancedGrid but I had the same error when I used DataGrid to create a dynamic and changing matrix and this is how I was able to fix it.

Your problem arises because:

  1. Your old structure property in the grid doesn't support the new store (different fieldnames etc.). If you don't get the structure right, Dojo complains and you don't see a grid.

  2. I'm pretty sure it's this one. grid.setStore(newStore) doesn't work the second time probably because grid adapts itself to the first declaration of the store. I had tried the grid.setStore() and grid.setStructure() methods and it didn't show up after the first "refresh".

My solution:

Empty your container with dojo.empty() and create a new grid in that container every time you refresh with your new store

Upvotes: 1

Related Questions