copy tables and change selected values
copy tables and change selected values
Hi,
there are quite a lot of threats how to copy rows from one table to another. I also need this, but:
* when copying change some values (especially for keeping track of what was copied)
* there is the header-table and also the items-table; when copying a line in the header-table, I would also want the items (same ID plus item-ID) to be copied
Is that possible and reasonable to do in datatable, or should I better build a function for that in php?
Thanks Max
This question has an accepted answers - jump to answer
Answers
Use
row().data()
to get the row to copy. Do any data manipulations. Then userow.add()
to copy/add that row to the destination table. Is this what you are looking for?Kevin
Yes, that solves question 1 - changing some values before inserting.
But how about question 2? To make my problem clearer, here a more detailed description:
table "offer header" has ID/date/customerNo/remarks
table "offer lines" has ID/lineNo/product/value
table "invoice header" has ID/date/customerNo/remarks
table "invoice lines" has ID/lineNo/product/value
I want to copy
"offer header" to "invoice header", putting "copy from offerID ..." into remarks; this should be possible with the APIs you named.
"offer lines" to "invoice lines" - here all rows with the same ID as in "header" are to be copied.
Thanks
Max
Sorry, I'm not clear on what the question is exactly. I put together this example to demonstrate:
http://live.datatables.net/nalesixe/1/edit
Kevin
I try to explain the question differently.
there are 4 tables.
With the code you posted in your eaxmple, we copy a row from table1 to table2. Lets assume the ID of this row is 345
Additionally I want to copy all rows from table 3 to table 4, where the value of column "ID_header" is 345
Thanks
Max
You can use
rows().data()
to get multiple rows. You can use therows()
row-selector
as a function to get the rows that match "ID_header" is 345. Then userows.add()
to add the rows to the second table. Note thes
for all the APIs to operate on multiple rows.Kevin