How to trigger editRow() for a specific row in a DataGrid?

Hi, I have a DataGrid InLine edit, and it works correctly.
When I click on the Edit button for a Row, it executes this code:

this.grid0.editRow(${data});

and it puts my row in Edit mode.

All good, now I want to have a button, that executes the same function, editRow(), but I Can pass to it a specific Row to put in Edit mode.

Is this possible? I tried passing to this function the exact copy of the ${data} object of one of my rows, but when I click this button, nothing will happen.

So how can I invoke this.grid0.editRow(${data}); for a Specific row, without clicking the Edit button on that row?

The editRow function expects the data item to be contained in the Data property of the DataGrid. This is why using a copy won't work. Usually the DataGrid is data-bound to a page property (e.g. getProductsResult). To edit say the second item you should use this.grid0.editRow(${getProductsResult[1]})

1 Like

ok thank you for the answer! Is there a way to use editRow() and instead of passing the Array position of the record I want to edit, to pass somehow the PK of that row?

You don't need to pass array position. You need to pass the item of the array at the specified position. You can find it via some code (including by PK):

this.grid0.editRow(${getProductsResult.find(p => p.ProductID == 1)})

1 Like

great informations, this will come in handy for sure! thank you