How can you access the Switch property on a row of data in a List Collection?
So for example, I'd like to sum the total of a property of all the items where the switch is On.
Or also get an array of all the List items that are on.
How can you access the Switch property on a row of data in a List Collection?
So for example, I'd like to sum the total of a property of all the items where the switch is On.
Or also get an array of all the List items that are on.
After playing a bit more, it seems you can only select one item in a list using the Switch action type.
So maybe I just need a suggestion how to achieve what I'm trying to.
I have a list of items I would like the user to select from, marking each to be included in the next action. The data comes from a postgres query. Somewhat like a Multi-Select.
The list could be a bit long for a multi-select, so I was thinking to use a List Collection. Perhaps event two Lists; moving an item from one to the other when selected.
Maybe I'm being too complicated and I just need an example of using the multi-select? That component isn't used in any of the example apps.
Hmm... it seems like for now using a Multi-Select may be the best option. It looks like it is possible to get similar behavior with a List Collection but it involves using a temp state to track selected values:
You can create a "Press" event handler that uses setIn
to change the value associated with your row's id
in your temp state:
You can then set the icon for each List Collection item based on the value of the state:
Beyond that all you need to do is make sure the state is initialized as an empty object:
Here's an example you can import and play around with!
Let me know if that works?