Zero record hidden after creating defaults
Zero record hidden after creating defaults
Misiu
Posts: 68Questions: 4Answers: 2
After moving my oLanguage to defaults zero record row is missing.
When I add oLanguage to dataTable initialization it works fine, but when I move it into $.extend($.fn.dataTable.defaults,{}) this row is hidden.
Please take a look at this demo: http://jsfiddle.net/PGM4b/
When page is loaded zero records row is hidden, when You change number of rows per page it is visible again.
Demo uses dataTables 1.9.0, but I'm using 1.9.4 and the results are the same.
When I add oLanguage to dataTable initialization it works fine, but when I move it into $.extend($.fn.dataTable.defaults,{}) this row is hidden.
Please take a look at this demo: http://jsfiddle.net/PGM4b/
When page is loaded zero records row is hidden, when You change number of rows per page it is visible again.
Demo uses dataTables 1.9.0, but I'm using 1.9.4 and the results are the same.
This discussion has been closed.
Replies
[code]
$.extend(true, $.fn.dataTable.defaults, {
"oLanguage": {
"sProcessing": "Proszę czekać...",
"sLengthMenu": "Ilość rekordów na stronie: _MENU_",
"sZeroRecords": "Brak rekordów",
"sInfo": "Pozycje od _START_ do _END_ z _TOTAL_ łącznie",
"sInfoEmpty": "Pozycji 0 z 0 dostępnych",
"sInfoFiltered": "(filtrowanie spośród _MAX_ dostępnych rekordów)",
"sInfoPostFix": "",
"sSearch": "Szukaj:",
"sUrl": "",
"oPaginate": {
"sFirst": "Pierwsza",
"sPrevious": "Poprzednia",
"sNext": "Następna",
"sLast": "Ostatnia"
}
}
});
[/code]
If I do so my table is displayed, but without localization.
Could You please show me the correct usage?
This particular part isn't working.
I didn't notice that there is another option in oLanguage that I must use.
It's a bit weird that when I add translation into dataTable initialization I see sZeroRecords translation in my row (when I initialize dataTable on empty table), but when I want to use it in default setting, using extend, I must specify another option - sEmptyTable.
I don't know if this is a true bug, but it's bit confusing.
I'm trying do move all my settings to $.extend, because I'm using the same table 3 times on a page, the only difference are the columns.
I'm trying to add "aLengthMenu" to my defaults.
When I use deep copy aLengthMenu is broken, when I remove true from extend language is broken.
Please take a look at: http://jsfiddle.net/PGM4b/5/
As You can see length menu has some weird options, but when You remove true from $.extend it works, but then initial translation is missing-row saying no data in table.
[code]
[ 10, 25, 50, 100 ]
[/code]
So when you extend it with your 2D array you actually get:
[code]
[
[25, 50, 100, -1],
[25, 50, 100, "Wszystkie"],
50,
100
]
[/code]
which confuses DataTables somewhat and we get the result that you see.
Possibly DataTables should take this into account, but is it effectively an invalid value. Rather than extending the aLengthMenu option - just assign it directly:
[code]
$.fn.dataTable.defaults.aLengthMenu = [[25, 50, 100, -1], [25, 50, 100, "Wszystkie"]];
[/code]
http://jsfiddle.net/PGM4b/6/
Allan
I found sample aLengthMenu in reference: http://datatables.net/ref#aLengthMenu so I was trying to do it this way.
Thank You for help!
Every time I use DataTables I get more and more amazed! :)