jbarlow
jbarlow

Reputation: 1518

Is there a way to force a single row refresh with 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).

Upvotes: 5

Views: 9147

Answers (2)

Aamir Shaikh
Aamir Shaikh

Reputation: 91

function updateSlickgrid() {
    dataView.setItems(tableName); 
    grid.invalidate();
}

Note : tableName could be the array or id etc. I prefer storing all the slickgrid data in the array ex tableName = [];

Keep using the above function when it comes to displaying the data in slickgrid

Upvotes: 0

njr101
njr101

Reputation: 9629

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)

Upvotes: 8

Related Questions