Trigger Query From ListView. How to Pass Item/Row Details

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.


image
image

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

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.

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

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