Copy selected rows and certain columns from one table to another.
Copy selected rows and certain columns from one table to another.
bbrindza
Posts: 316Questions: 73Answers: 1
Does anyone have a good working example of being able to copy selected data rows and only specific columns from one DataTable to another? I want to invoke a function to do this from a button click.
I saw some really good examples of copying an entire table to another, however I could not find what I was looking for.
Thanks in advance
This question has an accepted answers - jump to answer
Answers
How are you selecting the rows?
This example shows how to get the row data when the row is clicked. This example shows how to get the selected rows when using the Select extension.
Once you have the row data you can manipulate it if need before copying to the second table. Use
row.add()
orrows.add()
as appropriate to add the rows to the second table.Kevin
Using the Select Extension which gives me the input checkbox.
Kevin,
What about also being able to only bring over specific columns to the new table?
You have these columns in the source table:
Lets say you want only these columns:
You can simply use
row.add()
and Datatables will populate that row with all the source column data but only display the columns you define. Or you can use something like the delete operator to remove the objects you don't want to copy. You will need to manipulate the source data to match what you want to be copied.Kevin
Cool. I will get that a whirl. Thank you .