Using the "language" property when initializing a DataTable
Using the "language" property when initializing a DataTable
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
My apologies, part of the code was rendered in italic thanks to the underscores ( _ ), so here's the whole code properly:
Edit: And only now after posting this did I notice where we could find the option to edit posts. |:
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
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.
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