DataTables search child row content and SHOW this row

DataTables search child row content and SHOW this row

habnermhabnerm Posts: 1Questions: 0Answers: 0

****this is my code: BUT not work, I need to open the row when the information is found.****

// Add event listener for opening and closing details
$('#example tbody').on('click', 'td.details-control', function () {

    var tr = $(this).closest('tr');
    var row = table.row(tr);

    if (row.child.isShown()) {
        row.child.hide();
        tr.removeClass('shown');
    } else {
        row.child(details[row.index()]).show();            
        tr.addClass('shown');
    }

});




function filterByDetailsExtNoAndInput(term) {
  $.fn.dataTable.ext.search.push(
    function(settings, data, dataIndex) {
        if ($(details[dataIndex]).find('.extNo').text() == term){

              return true;
        } 

        for (var i=0;i<data.length;i++) {
            if (data[i].toLowerCase().indexOf(term.toLowerCase())>=0) {
                return true
            }    
        }    
    }    
  )
  table.draw();
  $.fn.dataTable.ext.search.pop();
} 

// Apply the search
table.columns().every( function () {
    $( 'input', this.footer() ).on( 'keyup change', function () {
        filterByDetailsExtNoAndInput(this.value);
    });
});

$('.dataTables_filter input')
   .off()
   .on('keyup', function() {
      filterByDetailsExtNoAndInput(this.value);
   }); 

This image shows what I want to achieve, but my code doesn't work

Replies

Sign In or Register to comment.