Dojo Gridx Refresh Table after specific action completed?

1.3k Views Asked by At

I have a grid created using Gridx which will be used to monitor and manage entries. When a user clicks a row of the table, a dialog pops up and allows the user to select ignore or respond. When either is clicked, I have to update an entry in my SQL database (the same table from which this information is getting pulled) and then I want the grid to refresh with the updated information.

Basically, AFTER the SQL database is updated based on what the user selects, I want the grid to refresh with the UPDATED information.

I am new to dojo and the user of stores so please have mercy :P.

My grid is created like this:

var memoryStore = new Memory();
var jsonRest = new JsonRest({target:url, idProperty:"username", sortParam: "sortBy"});
var store = new Cache(jsonRest, memoryStore);

var grid = new Grid({......});

/*this could be very wrong, but its the only way I could get 
  my data to load on first load - any corrections would be appreciated*/ 
store.query{{}).then(function() {
   grid.model.clearCache();
   grid.body.refresh();
});
grid.startup(); 

But I can't get it to refresh after the update? By the way, I am using a synchronous cache. Any help or suggestions would be greatly appreciated!

Thanks in advance

1

There are 1 best solutions below

0
On

You have to set "clearOnClose:true" and "urlPreventCache:true" while declaring the store. setting clearOnClose to true will enable your store to fetch the data again. Else, data is fetched only once, no matter if you use query.

So, after setting these parameters, when you need to reload, just close the store.

store.close();

Now, refresh the body. Data will reload successfully.

store.query().then(function() {
   grid.model.clearCache();
   grid.body.refresh();
});