I have a stale-data problem with dgrid grids. Assume the following scenario:
- Grid gets assigned to a JsonStore, it loads relevant data (e.g. GET /api/items)
- User selects an element, grid emits
dgrid-select
item which provides a reference to the actual object returned by the API call. - With that reference, operations occur and the application flow goes on, probably updating the item (e.g. PUT /api/items/1)
- The grid is manually refreshed (which in turns refreshes the store) so that it does not contain stale data (e.g. GET /api/items). Since the grid was created with the option
deselectOnRefresh: false
, the selected row is still the same.
At this point, how do I get a reference to the object with the updated data without making an extra call to the API?
I tried manually selecting the row again, but this would not fire the event. I also tried calling grid.row(selectedItemId)
but that returns the row object rather than the underlying object. I also tried calling store.get(selectedItemId)
and while it provides me with the updated object, it performs another call to the API, which would be unnecessary because that information has already been loaded by the app.