techguy2000
techguy2000

Reputation: 5161

ag-grid load a table with a row selected

I am refreshing the grid every second or so. Once a row is selected, I want to keep the same row selected on the next refresh. Is there a way to load the table with a row selected to maintain a stable selection (so that the user will feel that the row is always selected even with data refresh)?

Also, on every refresh, the rowData is a different object reference.

Upvotes: 3

Views: 4015

Answers (3)

RezKesh
RezKesh

Reputation: 2942

Since more than a year and half is passed, I hope my answer would be still useful.

You don't need to load the data with preselected row, or store selected rows somewhere and reselect them programatically when data is reloaded. The solution is to not overload the table rows every time you receive a new data.

For that you may use Transaction Updates which only updates cell values and keeps every other data (and metadata).

Upvotes: 0

Ajay Kumar
Ajay Kumar

Reputation: 9

With getRowNodeId functionuse

deltaRowDataMode = true 

Every row should have a unique id.

Upvotes: 0

Alexander Zbinden
Alexander Zbinden

Reputation: 2541

Unfortunately not out of the box. What you need to do is something like this:

  1. Before refreshing your data use api.getSelectedNodes() and store your unique key to identify the node/row
  2. Refresh data
  3. Iterate through your grid and compare Node/row with the stored key
  4. Select the found node/row manually by using node.setSelected(true);

Upvotes: 0

Related Questions