Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to force a single row refresh with SlickGrid?

Tags:

slickgrid

I have the amazing SlickGrid configured to access data asynchronously and post user changes back to the server asynchronously. In general terms, the server may modify a few fields of a row based on the user's changes. As such, after the row is updated I would like SlickGrid to refresh only that row without changing the rest of the view.

Does anyone know how to do this?

In my case, the field that changes on the server is a timestamp associated with the record that is updated by a database trigger. If the timestamp is out of date, the user has an old copy of data, and if they submit changes, they may overwrite a new copy. Since I can't find a way to trigger a refresh, the user cannot modify their own changes without refreshing the browser window (forcing a complete refresh).

like image 202
jbarlow Avatar asked Nov 15 '12 21:11

jbarlow


1 Answers

You should be able to do this using grid.invalidateRow() and grid.render(). SlickGrid will re-render the affceted rows (assuming they are displayed in the currently visible viewport) without refreshing the entire page.

// Mark row 42 as changed and re-render the display
grid.invalidateRow(42);
grid.render();

For an example check out SlickGrid Example 14. (Click the Start Simulation button to see it in action)

like image 175
njr101 Avatar answered Dec 24 '22 03:12

njr101