Possible to filter child table on page load?

Possible to filter child table on page load?

JoeJoeJoeJoeJoeJoe 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();

Answers

  • JoeJoeJoeJoeJoeJoe Posts: 50Questions: 13Answers: 1

    Problem solved by doing the following:

    $('#WTM_LOG').DataTable(
    "initComplete": function (settings, json) {
                    var xTable = $('#WTM_TABLE').DataTable();
                    var kTable = $('#WTM_LOG').DataTable();
                    rowDat = xTable.row(0).data();
                    kTable.row(0).columns(1).search(rowDat.TaskName).draw();
                },
    )
    
  • 54696d2054696d20 Posts: 75Questions: 18Answers: 0
    edited January 2019

    Also, this would have worked:

    var childTable = $('#WTM_LOG').DataTable(); childTable.columns(1).search(rowDat.TaskName).draw();

This discussion has been closed.