Internationalisation
Internationalisation
jiangdy
Posts: 6Questions: 0Answers: 0
Dear Sir,
I want to change oLanguage's content dynamically. I use the following code. but only "sInfo" was changed. Could other properties be changed ?
Hope you would like to give me a help.
[code]
$(document).ready(function() {
var dt = $('#example').dataTable( {
"oLanguage": {
"sLengthMenu": "Display _MENU_ records per page",
"sZeroRecords": "Nothing found - sorry",
"sInfo": "Showing _START_ to _END_ of _TOTAL_ records",
"sInfoEmpty": "Showing 0 to 0 of 0 records",
"sInfoFiltered": "(filtered from _MAX_ total records)"
}
} );
$("#testA").click(function(){
var changeLan = {
"sProcessing": "Bitte warten...",
"sLengthMenu": "_MENU_ Eintrage anzeigen",
"sZeroRecords": "Keine Eintrage vorhanden.",
"sInfo": "_START_ bis _END_ von _TOTAL_ Eintragen",
"sInfoEmpty": "0 bis 0 von 0 Eintragen",
"sInfoFiltered": "(gefiltert von _MAX_ Eintragen)",
"sInfoPostFix": "",
"sSearch": "Suchen",
"sUrl": "",
"oPaginate": {
"sFirst": "Erster",
"sPrevious": "Zuruck",
"sNext": "Nachster",
"sLast": "Letzter"
}
};
$.extend( dt.dataTableSettings[0].oLanguage, changeLan);
dt.dataTableSettings[0].oInstance.fnDraw();
});
} );
[/code]
I want to change oLanguage's content dynamically. I use the following code. but only "sInfo" was changed. Could other properties be changed ?
Hope you would like to give me a help.
[code]
$(document).ready(function() {
var dt = $('#example').dataTable( {
"oLanguage": {
"sLengthMenu": "Display _MENU_ records per page",
"sZeroRecords": "Nothing found - sorry",
"sInfo": "Showing _START_ to _END_ of _TOTAL_ records",
"sInfoEmpty": "Showing 0 to 0 of 0 records",
"sInfoFiltered": "(filtered from _MAX_ total records)"
}
} );
$("#testA").click(function(){
var changeLan = {
"sProcessing": "Bitte warten...",
"sLengthMenu": "_MENU_ Eintrage anzeigen",
"sZeroRecords": "Keine Eintrage vorhanden.",
"sInfo": "_START_ bis _END_ von _TOTAL_ Eintragen",
"sInfoEmpty": "0 bis 0 von 0 Eintragen",
"sInfoFiltered": "(gefiltert von _MAX_ Eintragen)",
"sInfoPostFix": "",
"sSearch": "Suchen",
"sUrl": "",
"oPaginate": {
"sFirst": "Erster",
"sPrevious": "Zuruck",
"sNext": "Nachster",
"sLast": "Letzter"
}
};
$.extend( dt.dataTableSettings[0].oLanguage, changeLan);
dt.dataTableSettings[0].oInstance.fnDraw();
});
} );
[/code]
This discussion has been closed.
Replies
Allan
Thank you for your reply. Probably difficult for me to write my own API. I hope someday I can do it.
I work in Tokyo. Datatables' code is still difficult for me to understand. I have two questions, hope you would like to teach me!
One question is:
why we can use code in the following way ? I just know I should use "$.fn.dataTableSettings" by the way of $("#id").dataTableSettings() ? Am I right ?
[code]
var dt = $('#example').dataTable(); .......;
$.fn.dataTableSettings[0].oApi._fnDraw( $.fn.dataTableSettings[0] );
[/code]
Second question is:
How can I catch the sort event of a column ? I want to sort a column by a checkbox that I added to that column. When I check that checkbox, and sort, the column will be sort by different column data.
Thank you very much !
[code]
var dt = $('#example').dataTable(); .......;
dt.fnDraw();
[/code]
2.
> How can I catch the sort event of a column ? I want to sort a column by a checkbox that I added to that column. When I check that checkbox, and sort, the column will be sort by different column data.
What you would need to do is unbind the default click listener that DataTables adds to the header cell, and then bind your own that will call fnSort with the sorting parameters you want, based on the condition of the checkbox.
Nothing like diving in at the deep end :-)
Allan
Thank you for your reply !
You know for some guys (like me), diving into the code deeply is very difficult. You mind, your intelligence all are required. But anyway I will try my best to make something. And if I still use datatables you made l will let you know. Thank you for your great plug-in !
Best regards
ジャン