Category: How do I do X?
Updated

This solution is summarized from an archived support forum post. This information may have changed. If you notice an error, please let us know in Discord.

How do I select the row while also opening a modal?

Issue

I am trying to create an "edit row" button that opens a modal and pre-populates with information from the row it was clicked in. However, the usual functionality of selecting the corresponding row when clicking on an interact-able cell has changed. I need to know how to reference the row where the button was clicked.

Resolution

To reference the row where a button was clicked in a table widget in Appsmith, use "triggeredRow" instead of "selectedRow". This will allow you to pre-populate a modal with information from the row where the button was clicked. Here is an example of the code you can use:



  1. Create a button in a table widget.

  2. Add an onClick event to the button.

  3. Set the action of the onClick event to "Show Modal".

  4. In the Show Modal action configuration, add a field that corresponds to the data you want to populate in the modal. For example, "Name".

  5. In the "Value" field for the "Name" field, enter this code "{{triggeredRow.Name}}".

  6. Save the configuration and run the app to test it.

This code will ensure that when the button is clicked, the modal will open with the data from the row where the button was clicked.