7

I have 2 data-table sharing the same jquery-dataTables-js because I cannot change it inside the JavaScript file, is there any alternate way that I can change it

I want to customize the default error message to my own.

No matching records found - We don't add anything yet No data available in table - no data of your choice.

Cœur
  • 37,241
  • 25
  • 195
  • 267
user2691372
  • 71
  • 1
  • 2
  • 4

4 Answers4

18

check this which sets your custom messages.

$(document).ready(function() {
    $('#data_table_id').DataTable( {
        "language": {
            "lengthMenu": "Display -- records per page",
            "zeroRecords": "No matching records found - We don't add anything yet No data available in table - no data of your choice.",
            "infoEmpty": "No records available"
        }
    } );
} );
sansarp
  • 1,446
  • 11
  • 18
0

See here for http://datatables.net/usage/i18n editing default datatable texts. Also here's an example http://datatables.net/examples/basic_init/language.html

Jompper
  • 1,412
  • 9
  • 15
0

You can also do it in initComplete like below. It is more flexible in terms of adding custom classes and designs

"initComplete": function(settings, json) {

        $('.dataTables_empty').html("<span class='label label-danger'>No records found</span>");

    }
sumit
  • 15,003
  • 12
  • 69
  • 110
0

I am using Datatable 1.10.12 and below code works for me:

"language": {
    "processing": '<div class="widget-loader" id="loader"><div class="load-dots"><span></span><span></span><span></span></div></div>',
    // show when no record found in a table...
    "emptyTable": '<h4 class="block text-center"><i class="fa fa-exclamation-triangle" style="color: #C49F47;"></i> {{ __("no_record_found") }}</h4>',
    // shown when no matching row found in filtering...
    "zeroRecords": '<h4 class="block text-center"><i class="fa fa-exclamation-triangle" style="color: #C49F47;"></i> {{ __("no_record_found") }}</h4>'
}

Refer: How to show empty data message in Datatables

Urja Satodiya
  • 412
  • 5
  • 10