Copy data from one table to another

I have two tables, one for searching a remote REST API and displaying results and one that I want to add rows to when they’re clicked in the first table.

In using Table(new) and setData doesn’t seem to be a function any more. How do I copy a row to the new table on click or on action?

@ithq_sn Welcome to the forum!
Someone else may have a better solution but here is what you can do:
In the In the Add line items table, add an event handler to run a js query named addLineItems
Then create a js query named addLineItems using the following code:

const addlineItems = [];
addlineItems.push(table15.selectedRow); // this is your Add line items table
if(lineItem.value[0] === null){
  lineItem.setValue(addlineItems);
} else {
  lineItem.setValue(lineItem.value.concat(addlineItems));
}

then create a temp state variable called lineItem

then set the source of your Line items table to be {{lineItem.value}}

There are couple of issues such as adding a duplicate line item, but can also add a delete action button in your Line Items table to remove it or add logic in the above JS query to check values as well OR once added remove the line item from the Add line items table.

Screenshot 2023-06-08 at 11.02.50 AM

1 Like