Actions buttons in a table with multiple select allowed?

When I have action buttons in a table, usually it's an easy thing to have a query take an action against that particular row of the table, for example, I can trigger a js query that uses table1.selectedRow to find the id of the row being edited, along with having actions select their row.

However, with multiple row select enabled (needed for another activity), if one clicks two action buttons in a row, I now have two selected rows and can't tell which one was clicked.

In this case, how can we determine which row to take the action upon? I don't see anything updated in the table outside of the selectedRow data element when an action button is clicked on that I can reference to determine which row had the action button clicked?

1 Like

I have the same situation. I have a Remove action button so the user just clicks the button on the row to delete it. The table is also multi-select. Here is the query:

DELETE from template_items
where template_item_id={{tblTemplateItems.data.template_item_id[i]}}

The secret here is that i is the index of the component which called the query.

How do you go about finding the index?

The variable i will be automagically passed to the query which is called by the button, whether that be a SQL query, JS query or any other kind. No further work needs to be done on your part.

1 Like

@gpipoly @bradlymathews is correct! The i index is automatically computed and updated as an iterable variable, which will allow for setting/getting values dynamically.

@sbhat is this documented anywhere?

I don't think it works anymore, currently trying to figure out how to get the data from clicked row

1 Like

Hello @mmmzir

the clicked row is the selected row and you can access the data via the selectedRow.

For edited rows, you can access them via the recordUpdates

No, we are talking specifically about table with multiselect enabled; selectedRow.data is an array of all selected rows. From just that it is not possible to find out which row's action has been clicked.

Basically, when multiselect is enabled, the selectedRow.data is now an array and having to click a single row would mean there are multiple items now in selectedRow.data. You can't just iterate over the array cause you want the specific row that you just clicked on

1 Like