Access values of components in ListView

Hi – I’m creating a listview and including a toggle for each item. I want to create a query that displays the values in a text component for each list item where the toggle is true. I’m stuck figuring out how to access listview items where a certain condition is true. Can anyone give advice on how to access the key/value pairs of the listview components in a SQL query?

Hey there @juliea and welcome to the community!

Assuming I understand your use case correctly, this is pretty straightforward - the ListView component has a .data property that tells you about the components in each row. So if you have a toggle set to true in the first row, for example, then listview.data['0'].toggle1 will evaluate to true.

Here’s a quick example I made locally - the property browser on the left hand side shows the properties I mentioned and their values.

If you want to filter that .data property for only items where the toggle property is true, you could use something like this:

listview.data.filter(item => item.toggle1)

Or the longer hand, listview.data.filter(item => item.toggle1 === true)

Let me know if this helps!

Thanks @justin that worked great!

1 Like