oLanguage in combination with sDom <"toolbar"> bug?
oLanguage in combination with sDom <"toolbar"> bug?
Arno
Posts: 3Questions: 0Answers: 0
Hi,
Compliments on Datatables!
When I try to use sDom to add a div class (like the example "DataTables Custom DOM additions") I noticed this doesn't work when I use it in combination with oLanguage. The "$("div.toolbar").html('Custom tool bar! Text/images etc.');" doesn't show.
When I comment out the oLanguage line, the Custom tool bar text is shown.
Is this a bug or am I doing something wrong?
Thanks,
Arno
Compliments on Datatables!
When I try to use sDom to add a div class (like the example "DataTables Custom DOM additions") I noticed this doesn't work when I use it in combination with oLanguage. The "$("div.toolbar").html('Custom tool bar! Text/images etc.');" doesn't show.
When I comment out the oLanguage line, the Custom tool bar text is shown.
Is this a bug or am I doing something wrong?
Thanks,
Arno
This discussion has been closed.
Replies
Allan: Is this a bug in datatables?
...
<?php
if ($language='es_ES') { ?>
"oLanguage": {
"sLengthMenu": "Mostrar _MENU_ registros por página",
"sZeroRecords": "No hay resultados",
"sInfo": "Mostrando _START_ a _END_ de un total de _TOTAL_ registros",
"sInfoEmpty"....}
<?php }
... and so with all my languages.
To solve this you can use fnInitComplete ( http://datatables.net/usage/callbacks#fnInitComplete ) which is fired once the table has fully initialised:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"oLanguage": {
"sUrl": "whatever"
},
"fnInitComplete": function () {
$("div.toolbar").html('Custom tool bar! Text/images etc.');
},
"sDom": '<"toolbar">frtip'
} );
} );
[/code]
Allan
Allen: I use a button instead off the "Custom tool bar" text. In your example the button doesn't seem to function anymore (the click event isn't picked up). Probably a coding error somewhere in my code. I am using Miyagin's option since that is the easiest and I don't have the time to investigate and rewrite the code..
Thanks for the help!
It looks like Miyagin's response but we don't have some IF/ELSE IF/... in the JS code :
Example :
[code]
$('#table').dataTable({
"sDom": 'blahblah',
"oLanguage": <?php include 'pathToYourLanguageDirectory/'.$userLanguage.'.js'; ?>,
});
[/code]
it will include the content of the EN.js or FR.js files into the oLanguage parameter.
The language files can be found here : http://datatables.net/plug-ins/i18n