Reputation: 599
I want hide my datatable when user applies filter and no records found, we can set custom msg, but my requirement is hide this table. below is my sample code.I am unable to figure which listener will help when no records found will hide table.
reportCardTbl = $('.standardDataTable').DataTable( {
"paging": false,
"scrollCollapse": true,
"paging": false,
"oLanguage": {
"sZeroRecords":function(){
//$(this) gives me TD, i tried to search $(this).parents("table").hide(); not working as TD is not in table
//here i want to hide table
}
}
} );
Upvotes: 1
Views: 1687
Reputation: 1816
Use fnDrawCallback:
reportCardTbl = $(".standardDataTable").dataTable({
"paging": false,
"scrollCollapse": true,
fnDrawCallback: function (settings) {
$(".standardDataTable").parent().toggle(settings.fnRecordsDisplay() > 0);
}
});
Upvotes: 1