zeroRecords not working

zeroRecords not working

Chiara_VigChiara_Vig Posts: 1Questions: 1Answers: 0
edited October 2019 in Free community support

Hello

I need to insert a custom message when my data tables is empty.
I am already using one file of one specific language like this:

$('#myid').DataTable({
           //other things
           language: {
                     url: "/js/Italian.json",
                     zeroRecords: "No records to display ITA"
           },
           //other things
})

In my json file the content is this:

{
    "sEmptyTable":     "Nessun dato presente nella tabella",
    "sInfo":           "Vista da _START_ a _END_ di _TOTAL_ elementi",
    "sInfoEmpty":      "Vista da 0 a 0 di 0 elementi",
    "sInfoFiltered":   "(filtrati da _MAX_ elementi totali)",
    "sInfoPostFix":    "",
    "sInfoThousands":  ",",
    "sLengthMenu":     "Visualizza _MENU_ elementi",
    "sLoadingRecords": "Caricamento...",
    "sProcessing":     "Elaborazione...",
    "sSearch":         "Cerca:",
    "sZeroRecords":    "La ricerca non ha portato alcun risultato.",
    "oPaginate": {
        "sFirst":      "Inizio",
        "sPrevious":   "Precedente",
        "sNext":       "Successivo",
        "sLast":       "Fine"
    },
    "oAria": {
        "sSortAscending":  ": attiva per ordinare la colonna in ordine crescente",
        "sSortDescending": ": attiva per ordinare la colonna in ordine decrescente"
    }
}

This code continues to show me the string that i set in the "sLoadingRecords".
And an error appears in the console:

datatables.min.js:61 Uncaught TypeError: Cannot read property 'length' of null
at datatables.min.js:61
at i (datatables.min.js:47)
at Object.success (datatables.min.js:48)
at j (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at x (jquery.min.js:4)
at XMLHttpRequest.<anonymous> (jquery.min.js:4)

Could anyone help me?

Thanks :smiley:

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

Answers

  • colincolin Posts: 9,003Questions: 0Answers: 1,501

    Hi @Chiara_Vig ,

    That looks fine at a glance. 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

Sign In or Register to comment.