In Ag-Grid: using selected row after clicked cell

Dear all,

I have the following dilemma regarding best practice and data safety:

Often I have a modal being open after a double click on an AGgrid. After the user interacts with the modal and submits (say, for changing some contents in a more complex way that I think is better via modal than cell editing), I want to have the full AGGrid row (often to make a transaction update to the Grid, with updated values).

However, I feel that using selectedRow as state in the submit callback may lead to some data corruption, as the row was not “just selected” …

So, my approach: I create the modal in a clientside callback, use the gridApi to access the row, and Store the row data in the modal. The data in this Store that I then use in the submit callback ;

What do you think? Should I simply use the rowData directly??

Hello @YuriAoto

If you give the grid a getRowId that is unique, you can use a rowTransaction update once the form is submitted.

Hello @jinnyzor

Thanks for the reply;

Ok, but if I have several columns, say a row data with fields:

{rowId, col1, col2, col3}

but at the moment of submitting the form I know only few of them, because the whole row data is not given at the double click callback. I thus have only col1 and rowId, for instance, if I double clicked at col1. If I return a transaction with

{‘update’: [{‘rowId’: knownRowID, ‘col1’: new_value}]}

the data at columns col1 and col2 are lost. So, as far as I can see, I have to do something like

original_row[‘col1’] = new_value

{‘update’: [original_row]}

You can use the selectedRows as you mentioned and update, the getRowId will maintain the selection even after the update as well.