Using the "language" property when initializing a DataTable

Using the "language" property when initializing a DataTable

donotsdonots Posts: 3Questions: 1Answers: 0
edited October 2016 in Free community support

Greetings,

Firstly, I was checking this page, and...

This is a very interesting example, but somehow, using the whole "language" property options hasn't changed any of the defaults for me when initializing my DataTable.

Are there any known issues for this? Here's my code:

        $('#datatable').dataTable({
            "aoColumnDefs": [{ "sType": "BRDate", "aTargets": [1] },
                             { "sType": "BRDateEmpty", "aTargets": [6] }],
            "language": {
                "lengthMenu": "Mostrar _MENU_ registros por página",
                "zeroRecords": "Vazio",
                "info": "Dados da página _PAGE_ de _PAGES_",
                "infoEmpty": "Nenhum dado encontrado.",
                "infoFiltered": "(filtrados a partir de _MAX_ registros ao todo)"
            }
        });

(Note: "BRDate" and "BRDateEmtpy" are table sorting data types I customized, which don't interfere with anything and work fine. For the record, though, I still did try removing the whole "aoColumnDefs" property from the code, but the "language" property problem persisted. I also tried using "oLanguage" instead of "language", and tried to even test to see if just pointing to an URL with the configuration (i.e. "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/Spanish.json") would work, but also didn't.)

Ideas? Any help would be very much appreciated. Thanks in advance.

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

Answers

  • donotsdonots Posts: 3Questions: 1Answers: 0
    edited October 2016

    My apologies, part of the code was rendered in italic thanks to the underscores ( _ ), so here's the whole code properly:

    $('#datatable').dataTable({
    "aoColumnDefs": [{ "sType": "BRDate", "aTargets": [1] },
    { "sType": "BRDateEmpty", "aTargets": [6] }],
    "language": {
    "lengthMenu": "Mostrar _MENU_ registros por página",
    "zeroRecords": "Vazio",
    "info": "Dados da página _PAGE_ de _PAGES_",
    "infoEmpty": "Nenhum dado encontrado.",
    "infoFiltered": "(filtrados a partir de _MAX_ registros ao todo)"
    }
    });
    

    Edit: And only now after posting this did I notice where we could find the option to edit posts. |:

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

  • allanallan Posts: 63,230Questions: 1Answers: 10,416 Site admin

    Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.

    Information on how to create a test page, if you can't provide a link to your own page can be found here.

    Thanks,
    Allan

  • donotsdonots Posts: 3Questions: 1Answers: 0

    I ended up discovering the answer: the reason it wasn't working is indeed because I was using "language" as opposed to "oLanguage", but that alone wasn't it: I also had to change the property names adequately:
    "lengthMenu" -> "sLengthMenu"
    "zeroRecords" -> "sZeroRecords"
    "info" -> "sInfo"
    "infoEmpty" -> "sInfoEmpty"
    "infoFiltered" -> "sInfoFiltered"

    Is this change related to there being different versions of bootstrap? I'm not all that well-versed in all of the Bootstrap and Bootstrap DataTables version differences, if so. I also couldn't find documentation here talking of "oLanguage", but only "language" instead. I wonder if I just didn't see it?

    Regardlessly, I appreciate the attention. I just hope less people will be in my situation.

  • allanallan Posts: 63,230Questions: 1Answers: 10,416 Site admin

    Is this change related to there being different versions of bootstrap?

    No. It is possible it is related to your DataTables version though. If you are using the legacy v1.9.x or earlier versions you would need to use the Hungarian notation as you have done.

    The camelCase notation was introduced in 1.10.

    Allan

This discussion has been closed.