How can I prevent the jquery dataTable plugin from adding row and message when there is no data

后端 未结 5 1875
执念已碎
执念已碎 2020-12-20 16:46

Our product owner would like the our empty tables to display just table header when there is no data in table. I can\'t seem to prevent dataTable from creating a row with \"

相关标签:
5条回答
  • 2020-12-20 17:11

    try this

    $('#InBox').dataTable({
      "bFilter": false,
       "bPaginate": false,
       "bLengthChange": false,
       "bInfo": false,
       "oLanguage": {
        "sEmptyTable": '',
        "sInfoEmpty": ''
       },
       "sEmptyTable": "There are no records",
     });
    

    otherwise you can try this

    $('#InBox').dataTable({
      "bFilter": false,
       "bPaginate": false,
       "bLengthChange": false,
       "bInfo": false,
       "oLanguage": {
        "sEmptyTable": '',
        "sInfoEmpty": ''
       }
     });
    $('.dataTables_empty').html("No record found.");
    
    0 讨论(0)
  • 2020-12-20 17:25

    Old post, but for the sake of people using search engines looking for the right answer here is how I accomplished.

    Delete or comment out the following line from the dataTables source:

    anRows[iRowCount].appendChild(nTd);
    

    In the minified version, search and delete:

    b[i].appendChild(c);
    
    0 讨论(0)
  • 2020-12-20 17:25

    If you want to remove the tbody attacched from datatable plugin, you can try this workaround:

    $('.dataTables_empty').parent().parent().remove();
    
    0 讨论(0)
  • 2020-12-20 17:29

    The most current way to hide the messages is by using the language option

    $('#loggedMessages').DataTable({
        "language": {
           "emptyTable": ' ',
           "zeroRecords": ' '
         }
     });
    
    0 讨论(0)
  • 2020-12-20 17:34

    You can customize DataTable plugin by using oLanguange:

    "oLanguage": { "sZeroRecords": "-Put customized text-", "sEmptyTable": "-Put customized text-" }
    
    And if you want to remove those, just put these components into null:
    "oLanguage": { "sZeroRecords": '', "sEmptyTable": '' }
    

    Hope it helps!

    0 讨论(0)
提交回复
热议问题