Table "Button" column: passing row index to query

I have a table with a column of type "Button". When I click that button, I want to call a query with the row index of that button (or the sourceRow of that button).

My table has row selection set to "None", as this table displays data, and I don't need to allow row selection for any purpose.

The problem is that, when I try to pass {{ i }} as an additional scope variable to the query, its value is always "0", no matter the row of the button I clicked.

I wonder if there is a way of passing the index of the row clicked to the query, without an awkward workaround.

Thanks.

1 Like

Hey there @Javi_V,

Indeed, when you change yoru setting to "None" in row selection, you no longer have access to the "selectedDataIndex" property which would help you

An alternative, which may qualify as an awkward workaround :sweat_smile:, is to add a hidden column and use {{ i }} as mapped value, then you can use {{ currentSourceRow.myhiddencolumn }} as reference to pass the index value.

The problem with this solution is that currentSourceRow will always refer to the first row in the table (if I keep row selection as None).

To be honest, what bothers me about allowing row selection is just the blue background color that the selected row adopts, as it confuses my users. Is there a way to disable that style?

Ah yes, you're right.

You can remove the background by applying 0% transaprency to accent and hover row background

image

Quick thought about this:

You should be able to map your source data's PK (if it exists) against the current row's value. Whatever is providing the data to the table isn't going to change so you just need something like:

{{ query2.data.findIndex(data => data.id == currentSourceRow.id) }}

where the ID is the PK for the table:

image

Then you should be able to use this to send the original index along to your query.

1 Like