I've got more questions about accessing/manipulating a checkbox in a listview.
Here is the overview:
I've got three "overall" checkboxes:
- Select All
- Assembly Required
- Non-printed
Then I have a list view with a checkbox. Hook it up to my data source and I get a list of checkboxes where the labels represent order numbers.
Select All box - when ticked, selects all the orders. When unticked, deselects all the orders. Assembly Required and Non-printed work similarly, just with logic regarding some status of the orders.
Now, to implement the above, I used a JS Query called checkboxBehavior. When Select All, Asssembly Required or Non-printed checkbox changes, it calls this JS Query. The output of this query is an array of bools, that output is connected to the ListView Checkbox.
Overall this is working. Manipulate one of these three overall selectors and it changes the list as you would expect.
Next step for me then is to make it so they overall checkboxes play well when one is ticking/unticking individual boxes. Let's say someone uses Select All and then unticks one particular order. Well the select all should become unticked.
So on the checkbox in ListView I add an on change event to also call the JS Query checkboxBehavior. However now I get an error: Cannot read properties of undefined (reading length).
I think this is referring to this element in the JS query: listView_orders.data.length
So maybe the scope is different based on the caller? That makes sense, but I'm not familiar enough with JS or Retool to know how to resolve this. Or maybe there is a better way to implement the desired behavior.
But I'm not sure how best to handle this case. I need an array for the checkboxes to update to. So I went the JS query route.