Mistake with internationalisation
Mistake with internationalisation
Mathieu
Posts: 2Questions: 0Answers: 0
Hi,
When I using an external translation file http://datatables.net/plug-ins/i18n (the french translation case)
[code]
$('#tableTicketsProcheSla').dataTable({
"oLanguage": {
"sUrl":"js/Frameworks/jquery/internationalisation/datatable_french.txt"
}, ... });
[/code]
I obtain the following message :
[quote]TypeError : str is undefined[/quote]
at jquery.datatable.js at line 2567.
When I search the line in case of that mistake, I found the sOut as undefined at line 1509 of the datatable file, the variable sZero is initialized [quote]oLang.sZeroRecords[/quote] at line 1499.
I solve the problem by added the following code
[code]
else if ( sZero === undefined )
{
sZero = "";
}
[/code]
at line 1509.
An other solution is to include the content of the translation directly in the js file I wrote like this :
[code]
$('#tableTicketsProcheSla').dataTable({
"oLanguage": {
...the translation copy...
}, ... });
[/code]
This error appear when I apply a filter on column (the last line).
Maybe I don't use datatable correctly, if you have any idea why I obtain the undefined value whitout modification of datatable framework.
My code :
[code]
function sortTableSla( userName )
{
var tableProcheSla = $('#tableTicketsProcheSla').dataTable({
"oLanguage": {
"sUrl":"js/Frameworks/jquery/internationalisation/datatable_french.txt"
},
"aoColumnDefs": [
{ "sWidth": "50px" , "aTargets": [ 0 ] },
{ "sWidth": "350px", "aTargets": [ 1 ] },
{ "sWidth": "100px", "aTargets": [ 3 ] },
{ "sWidth": "100px", "aTargets": [ 4 ] },
{ "sWidth": "100px", "aTargets": [ 5 ] },
{ "sWidth": "170px", "aTargets": [ 6 ] }
],
"bStateSave": true,
"iDisplayLength": 10,
"bLengthChange": false,
"bAutoWidth": false,
"bDestroy": true,
"aaSorting":[ [4,'asc'] ]
}).columnFilter({
sPlaceHolder: "head:after",
aoColumns: [
{ type: "text" },
{ type: "text" },
{ type: "select" },
{ type: "date-range" },
{ type: "date-range" },
{ type: "select" },
{ type: "select" }
]
});
var found = false;
$('#tableTicketsProcheSla').find("select").each(function( index ){
try{
$(this).find("option").filter(function(){
if( $(this).text() == userName ) found = true;
return $(this).text() == userName;
}).prop('selected', true);
}catch (e) {
console.log(e);
}
});
//
if( !found )
{
var divParent = $("#tableTicketsProcheSla").parent();
var newDiv = createDivForDataTable("tableTicketsProcheSla", userName, 2 );
divParent.append( newDiv );
}
tableProcheSla.fnFilter( userName, 2 );
}
[/code]
Thanks for your help,
Regards,
Mathieu
When I using an external translation file http://datatables.net/plug-ins/i18n (the french translation case)
[code]
$('#tableTicketsProcheSla').dataTable({
"oLanguage": {
"sUrl":"js/Frameworks/jquery/internationalisation/datatable_french.txt"
}, ... });
[/code]
I obtain the following message :
[quote]TypeError : str is undefined[/quote]
at jquery.datatable.js at line 2567.
When I search the line in case of that mistake, I found the sOut as undefined at line 1509 of the datatable file, the variable sZero is initialized [quote]oLang.sZeroRecords[/quote] at line 1499.
I solve the problem by added the following code
[code]
else if ( sZero === undefined )
{
sZero = "";
}
[/code]
at line 1509.
An other solution is to include the content of the translation directly in the js file I wrote like this :
[code]
$('#tableTicketsProcheSla').dataTable({
"oLanguage": {
...the translation copy...
}, ... });
[/code]
This error appear when I apply a filter on column (the last line).
Maybe I don't use datatable correctly, if you have any idea why I obtain the undefined value whitout modification of datatable framework.
My code :
[code]
function sortTableSla( userName )
{
var tableProcheSla = $('#tableTicketsProcheSla').dataTable({
"oLanguage": {
"sUrl":"js/Frameworks/jquery/internationalisation/datatable_french.txt"
},
"aoColumnDefs": [
{ "sWidth": "50px" , "aTargets": [ 0 ] },
{ "sWidth": "350px", "aTargets": [ 1 ] },
{ "sWidth": "100px", "aTargets": [ 3 ] },
{ "sWidth": "100px", "aTargets": [ 4 ] },
{ "sWidth": "100px", "aTargets": [ 5 ] },
{ "sWidth": "170px", "aTargets": [ 6 ] }
],
"bStateSave": true,
"iDisplayLength": 10,
"bLengthChange": false,
"bAutoWidth": false,
"bDestroy": true,
"aaSorting":[ [4,'asc'] ]
}).columnFilter({
sPlaceHolder: "head:after",
aoColumns: [
{ type: "text" },
{ type: "text" },
{ type: "select" },
{ type: "date-range" },
{ type: "date-range" },
{ type: "select" },
{ type: "select" }
]
});
var found = false;
$('#tableTicketsProcheSla').find("select").each(function( index ){
try{
$(this).find("option").filter(function(){
if( $(this).text() == userName ) found = true;
return $(this).text() == userName;
}).prop('selected', true);
}catch (e) {
console.log(e);
}
});
//
if( !found )
{
var divParent = $("#tableTicketsProcheSla").parent();
var newDiv = createDivForDataTable("tableTicketsProcheSla", userName, 2 );
divParent.append( newDiv );
}
tableProcheSla.fnFilter( userName, 2 );
}
[/code]
Thanks for your help,
Regards,
Mathieu
This discussion has been closed.
Replies
Thanks,
Allan
the HTML code :
[code]
<!-- ID bdd -->
Identifiant
Titre
User
Date SLA
Date de cloture
Priority
Root cause
Ident
Title
User
Date SLA
Date de cloture
Priority
Root cause
ident
titre
User1
date1
date2
test
test
ident
titre
User1
date1
date2
test
test
ident
titre
User1
date1
date2
test
test
ident
titre
User1
date1
date2
test
test
ident
titre
User1
date1
date2
test
test
ident
titre
User2
date1
date2
test
test
ident
titre
User1
date1
date2
test
test
[/code]
and the javascript code :
[code]
$(document).ready(function(){
sortTableSla("User3");
});
function sortTableSla( userName )
{
var tableProcheSla = $('#tableTicketsProcheSla').dataTable({
"oLanguage": {
"sUrl":"datatable_french.txt"
},
"aoColumnDefs": [
{ "sWidth": "50px" , "aTargets": [ 0 ] },
{ "sWidth": "350px", "aTargets": [ 1 ] },
{ "sWidth": "100px", "aTargets": [ 3 ] },
{ "sWidth": "150px", "aTargets": [ 4 ] },
{ "sWidth": "100px", "aTargets": [ 5 ] },
{ "sWidth": "170px", "aTargets": [ 6 ] }
],
"bStateSave": true,
"iDisplayLength": 10,
"bLengthChange": false,
"bAutoWidth": false,
"bDestroy": true,
"aaSorting":[ [4,'asc'] ]
}).columnFilter({
sPlaceHolder: "head:after",
aoColumns: [
{ type: "text" },
{ type: "text" },
{ type: "select" },
{ type: "date-range" },
{ type: "date-range" },
{ type: "select" },
{ type: "select" }
]
});
var found = false;
$('#tableTicketsProcheSla').find("select").each(function( index ){
try{
$(this).find("option").filter(function(){
if( $(this).text() == userName ) found = true;
return $(this).text() == userName;
}).prop('selected', true);
}catch (e) {
console.log(e);
}
});
//
if( !found )
{
var divParent = $("#tableTicketsProcheSla").parent();
var newDiv = createDivForDataTable("tableTicketsProcheSla", userName, 2 );
divParent.append( newDiv );
}
tableProcheSla.fnFilter( userName, 2 );
}
function createDivForDataTable( datatable, userName, indexColumn )
{
var divAlert = $("");
divAlert.append("Aucune entrée trouvée correspondant à l'utilisateur "+ userName +"");
var button = $("");
divAlert.append(button);
divAlert.css("margin-top", "20px");
divAlert.css("margin-left", "20px");
return divAlert;
}
[/code]
I have the same issue, but with the version 1.9.4, someone could find a solution?