jonj
July 11, 2023, 1:57pm
1
I want to use an event handler in a listview item (components within a container), to trigger a query (to add that item to a table), when a checkbox is set to true.
In the query I've tried listview1.data[i]....(as seen here ) but it doesn't find that value.
Would appreciate any pointers.
Thanks,
Jon.
ScottR
July 11, 2023, 2:39pm
2
This might work: {{listView1.data.map(i=>i.checkbox1)}}
I only built it to test if the map function could potentially solve your issue:
1 Like
jonj
July 11, 2023, 5:07pm
3
Thanks Scott,
That's a really useful idea. Mapping is something new to me and I didn't know it was possible.
I get the same array result, but haven't worked out (yet) how to separate the different checkbox states.
ScottR
July 11, 2023, 5:43pm
4
You can take the mapping value and store it in a temp state variable and then iterate over the temp state:
and then your event handler for the check box would trigger a JS Query that would contain something like this:
for(let i=0; i<state1.value.length;i++){
if(state1.value[i] === true)
await addToList.trigger({
additionalScope: {
yourCheckBoxValue: state1.value[i],
},
});
}
addToList query would have the value for proc.. key as {{yourCheckBoxValue}}
instead of listView1.data[i]
3 Likes
jonj
July 13, 2023, 11:35am
5
Thanks again Scott.
Thank you for taking the time and explaining so well. You are always so helpful in this community and I always appreciate seeing your replies.
I've been sidetracked with other activities, and haven't had a chance to test this fully yet.
2 Likes