Return data from Table in Perspective from user click

Hello,
I am trying to collect the data from a row that the user clicks on in Perspective (Ignition v 8.0.2). When a user clicks on a row of the table, I want to be able to use the values from each column in an SQL query. For example, City= “San Diego”

Thanks!

David

DatafromTable_Perspective

There is some ambiguity in your question.

Do you mean you’ll be doing this EVERY TIME a user clicks, or you will possibly be doing it only occasionally?

If you’ll be running a query EVERY TIME:
use the onRowClick() component function. You’ll receive an object like this by referencing event.value:
{"city":"Prague","country":"Czech Republic","population":1241664}

If you’ll only be running the query occasionally:
You COULD do the same thing as was just discussed and then save the object to some variable and read as-needed, or you could fall back onto Table.props.selection.data, which stores an array of the selected rows and their information. Instead of the previously discussed object, you’ll receive an array of selected row objects with the same structure, so clicking a row in a table which only allows for single selection would return [{"city":"Prague","country":"Czech Republic","population":1241664}]

1 Like

Thank you very much! The table.props.selection.data was exactly what I needed!

2 Likes