Possible to filter child table on page load?
Possible to filter child table on page load?
JoeJoeJoe
Posts: 50Questions: 13Answers: 1
I have two tables. The parent table automatically selects the first row on page load and the child table filters the data depending on which parent table row has been clicked on. The on Click function works perfectly fine, however the child table does not filter as expected when the page initially loads and the first row of the parent table is auto-selected. I tried using .prop to force "selected" on the row, but it does not work. Any ideas? This is my code. Thanks:
$('#parentTable').DataTable({
"initComplete": function (settings, json) {
parentTable.row(':eq(0)', { page: 'current' }).select();
//COMMENTED OUT DOES NOT WORK
//var selRow = kTable.row(':eq(0)', { page: 'current' });
//kTable.prop("selected", true);
})
var rowDat = parentTable.rows({ selected: true }).data();
childTable.columns(1).search(rowDat.TaskName).draw();
This discussion has been closed.
Answers
Problem solved by doing the following:
Also, this would have worked:
var childTable = $('#WTM_LOG').DataTable();
childTable.columns(1).search(rowDat.TaskName).draw();