DataTables Rows Reorder - Sorting failure when adding same row again
DataTables Rows Reorder - Sorting failure when adding same row again
DataTable 1: Select row to add to DataTable 2
DataTable 2: Reorderable Table. Have a column ID.
Second datatable shall be like as a playlist. You can add rows multiple times from the DataTable 1.
When i select a row on the left side and click on my add-button, it will copy it to the second table.
But it is copying as a reference. After adding, i have to same rows with same IDs, so that ReOrder won't work anymore.
table2.rows('.active').every( function ( rowIdx, tableLoop, rowLoop ) {
let data = this.data();
data.id = table3.data().count()+1;
console.log(data.id);
table3.row.add( data ).draw()
} );
How can i add the rows as a new row, so that they are not coupled?
This question has an accepted answers - jump to answer
Answers
Take a look at this Stack Overflow thread for options to clone Javascript objects. Sounds like this is what you are looking for. If not please post a link to your page or a test case replicating the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin
Thanks, worked perfectly for me!
Best wishes, Kevin.