two datatables sync
two datatables sync
I have two tables filled with one dataset. the number of columns is different, but the indexing is the same. it is required to synchronize the selected table rows. when a row with index 3 is selected in one table, then in another table the row with index 3 should be automatically selected and vice versa.
let commonIdx;
$("#docsTableMin").dataTable().find("tbody").on('click', 'tr', function () {
commonIdx = this.rowIndex;
console.log(commonIdx);
});
$('#docsTable').DataTable().row(':eq('+commonIdx+')', { page: 'current' }).select();
manager.selectedDocument = manager.docs[commonIdx - 1];
i can get the index of the highlighted row in the table, but cant get the second table to highlight the row with that index.
sorry for my bad english
Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide
This question has an accepted answers - jump to answer
Answers
Does it highlight any rows?
Maybe you need to move line 8 inside the click event handler, ie, insert it at line 5.
I haven't used
this.rowIndex
. What is the value when clicking on the first row? The first element with jQuery :eq() is 0.If you still need help please provide a simple test case so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin