How do I detect a cell click?

I need to take action when a user clicks on a specific table column cell (it can be any row).

I do not want this to trigger when the user clicks on any other column.

How do I do that?

Thanks.

image

@Francis
Looking at your example, SignalID is the column you want a user to be able to click on any value in that specific column and trigger a query?

Correct. Each row has a different value for SignalID, so SignalID will be a parameter of the query.

you would have to use a js query to pass in that value as
yourtable.selectedRow.data.SignalID using additionalScope as documented here:
https://docs.retool.com/docs/scripting-retool#triggering-a-query

OK but how do I detect a click on that specific column? I don't want this to trigger if the user clicks on any other column. Action buttons are big and cumbersome. Alternatively, is there a way to generate a programmable right-click menu popup?

Your query would have to limit only that that row selected and the specific column and in this case it is SignalID, Even if a user selects another column, the query should only use SignalID - If I am reading your question correctly.

But I don't want this to trigger if the user clicks on any other column than 'signalid'. Clicking on a different column should trigger a different query. It's basic UI functionality. Clicking on a specific cell results in specific behavior. Is that possible with retool?

Hey @Francis! This is definitely possible :blush:

Tables have a .selectedCell property which includes the value of the selected cell, as well as the column name of the selected cell.

You can set your event handler to only trigger the query if the column name matches the 'signalid' column, like so:

{{table1.selectedCell.columnName == "email" }}

Let me know if you have any questions at all!

1 Like