if datatable is empty then it should show "No data available in table." by default , but it's not ?

if datatable is empty then it should show "No data available in table." by default , but it's not ?

mayureshdeshmukhmayureshdeshmukh Posts: 2Questions: 1Answers: 0

I tried by many was but not succeded.
$('#example').dataTable({
"oLanguage": {
"sEmptyTable": "My Custom Message On Empty Table"
}
});
Also
$('#example').dataTable( {
"language": {
"emptyTable": "No data available in table"
}
} );

Also
$('#example').dataTable( {
"language": {
"infoEmpty": "No entries to show"
}
} );
Nothing worked !

Answers

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794

    Your first code snippet is using legacy for of the options. See the Legacy Conversion Guide for details. But it does work here:
    http://live.datatables.net/moburipi/1/edit

    The second and third code snippets work also. I combined them in this example:
    http://live.datatables.net/meyehufa/1/edit

    Please post a link to your page or a test case showing the issue so we can help debug.

    Kevin

  • mayureshdeshmukhmayureshdeshmukh Posts: 2Questions: 1Answers: 0
    edited October 2022
      var table = $('#certification_master_list').DataTable({   
        "paging": false,
        "oLanguage": {
          "sEmptyTable": "My Custom Message On Empty Table"
        },
        "language": {
          "emptyTable": "Nooo data",
          "infoEmpty": "No entries to show"
        },
        "rowCallback": function( row, data, index ) {
                if(index%2 == 0){
                    $(row).removeClass('myodd myeven');
                                            $("td", row).css('background-color','#eef7ff');
                            $("td", row).css('font-size','18px');
                            $("td", row).css('font-family','Gothic A1');
    
                    $(row).addClass('myodd');
                }else{
                    $(row).removeClass('myodd myeven');
                     $(row).addClass('myeven');
                            $("td", row).css('background-color','#cce6ff');
                            $("td", row).css('font-size','18px');
                            $("td", row).css('font-family','Gothic A1');
                     
                }
              },
                "lengthChange": true,
                bFilter: false, bInfo: false,
    
            scrollX: true,
            scrollY: 500   
            });
    

    Edited by Kevin: Syntax highlighting. Details on how to highlight code using markdown can be found in this guide

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794

    oLanguage is the legacy form of the legacy option. You can only have one of them. One will overwrite the other.

    As I said we will need to see the problem to help debug. My examples show the options work so it is something specific to your solution.

    Kevin

Sign In or Register to comment.