Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show empty data message in Datatables

Suppose i get empty data from server sometimes, i want to display No Data found message in DataTables?. How is this possible?

like image 772
Naruto Avatar asked Jan 17 '13 09:01

Naruto


People also ask

How do I change the default empty table message in DataTable?

DataTable({bFilter: false, bInfo: false, paging: false}); It works fine.

How do I empty a DataTable?

function clear() Simply remove all rows of data from the table.


2 Answers

If you want to customize the message that being shown on empty table use this:

$('#example').dataTable( {
    "oLanguage": {
        "sEmptyTable":     "My Custom Message On Empty Table"
    }
} );

Since Datatable 1.10 you can do the following:

$('#example').DataTable( {
    "language": {
        "emptyTable":     "My Custom Message On Empty Table"
    }
} );

For the complete availble datatables custom messages for the table take a look at the following link reference/option/language

like image 107
Daniel Avatar answered Oct 23 '22 05:10

Daniel


Later versions of dataTables have the following language settings (taken from here):

  • "infoEmpty" - displayed when there are no records in the table
  • "zeroRecords" - displayed when there no records matching the filtering

e.g.

$('#example').DataTable( {
    "language": {
        "infoEmpty": "No records available - Got it?",
    }
});

Note: As the property names do not contain any special characters you can remove the quotes:

$('#example').DataTable( {
    language: {
        infoEmpty: "No records available - Got it?",
    }
});
like image 17
Gone Coding Avatar answered Oct 23 '22 04:10

Gone Coding