how to hide binfo and pagination when the table is empty?

how to hide binfo and pagination when the table is empty?

yousrafarooqyousrafarooq Posts: 1Questions: 1Answers: 0

I have binfo and paginaton true. but I want that whenever datatable is empty the binfo and pagination should hide and I could not get any idea about how to achieve it.I tried to hide the whole table but then it is not displaying the empty table message. Here is my code...

///////javascript//////

$(function () {
$('#example1').DataTable({
"paging": true,
"lengthChange": false,
"searching": false,
"ordering": true,
"info": true,
"autoWidth": false,
"iDisplayLength": 5,
"responsive": true,
"pagingType": "full_numbers",
"bSort" : false,
"order": [],
"aoColumns": [
{ "bSortable": false },
{ "bSortable": false },
{ "bSortable": false }],
"language": {
"emptyTable": '

image
'+'
No Accounts Found!

'}
});
var table = $('#example1').DataTable();
if ( ! table.data().count() ) {
$('.thead-example1').hide();
}
});

///////html//////

Provider Expiry date
a 29/05/2020 16:05 Disconnect
b 29/05/2020 16:05 Disconnect
c 29/05/2020 16:05 Disconnect
d 29/05/2020 16:05 Disconnect
e 29/05/2020 16:05 Disconnect

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

This discussion has been closed.