Filtering results in table2 based on "enabled multi-row selection" in table1

i found another pretty similar, but not close enough as i'm still very much learning.

i have two tables. table1 allows for multi-select and ideally, i want only the matching records in table2 to be displayed if they're selected in table1.

the query for table1 returns all the items belonging to a contract, along w/ their "PTID" and the query for table2 returns ALL the orders where these contract items have been ordered.

ideally, i would like ALL the checkboxes (rows) PRE-selected, displaying all the orders in table2, and allowing the user to uncheck items in table1 which would subsequently remove them from table2 results. (that's a different issue i haven't attempted to tackle, but bonus pts if you help with that issue. lol)

i don't really feel like hitting the DB each time a checkbox is checked, esp when i already have the data for the orders, i just want to hide the orders that correspond to the unchecked checkboxes.

i'm assuming i should be using a transformer and doing some kind of filter?

here's a picture of what i mean:

Hey @!

It sounds like a transformer could work here. Maybe if you pass something like the following to your second table's data field?

{{ YOUR_TABLE_DATA.filter(row => _.map(YOUR_OTHER_TABLE.selectedRow.data, "ID_COLUMN_IN_OTHER_TABLE").includes(row.ID_COLUMN)) }}

For selecting all rows you might use a script that runs when you first fetch the table data :thinking: something like:

YOUR_TABLE.selectRow(YOUR_TABLE.data.map((_, i) => i));

Once your table has data in it, that maps over the data and pulls out an array of every index to select!

Let me know if that helps! You can play around with it by importing the attached app :slightly_smiling_face:
match_selected_rows.json