Goal: I want to create a very basic collectionView where each item includes a text, description, and a toggle switch. Ultimately, I want to save the data (along with additional details about the selected day) to the Retool database to track my habits throughout the year.
Details: The behavior of selectedItem is quite inconsistent. I tried adding an empty runScript event to the outermost container, as suggested in a forum thread, but it only works when you click very precisely. For instance, clicking on the text or description does not trigger the selectedItem. In the table component of standard Retool apps (not mobile), clicking a button also selects the corresponding row as the active one, which I believe should be the case for this component as well.
I've come across similar discussions in the forum, but it seems like the issue persists.
Hey, thanks! I found a workaround by using collectionView.data[i] for my needs, but this really should be addressed. It’s been an issue for over a year now and is such a basic functionality that's essential for practically every app, in my opinion.
Yes, I agree. I actually came back to say, that my solution only solve sit temporarily. If you leave the app, then it stops working. And to get it to work again, I need to reset state and it works again. I am going to try your method.
Let me try building this out and see if I can reproduce this bug or find a work around.
So from my understanding, you want a collection view to have a list of items, each with their own toggle switch.
Then once you have toggled the items on or off, you want to run a query to pass the data of which items had which toggle statuses to Retool Database, correct?
You should be able to use a button to trigger this query, and grab the data out of the collectionView via the component's using the index of the item and the .value property of the switch component.
Then you would just need to use the same index to grab the data of the corresponding item from the container item!
Check out this vid for how to get the toggle data. You would just need a JS script to run on your 'submit' button click that would look through the indexes of the switches and their corresponding list items, save this combined data to a single object to hold the item data and toggle data together and then pass this to a query