Quantcast
Channel: DataTables 1.9 — DataTables forums
Viewing all articles
Browse latest Browse all 1816

Mistake with internationalisation

$
0
0

Hi,<br />
<br />
When I using an external translation file <a href="http://datatables.net/plug-ins/i18n" target="_blank" rel="nofollow">http://datatables.net/plug-ins/i18n</a (the french translation case)<br />
<code class='multiline brush: js;'>
$(&#039;#tableTicketsProcheSla&#039;).dataTable({
&quot;oLanguage&quot;: {
&quot;sUrl&quot;:&quot;js/Frameworks/jquery/internationalisation/datatable_french.txt&quot;
}, ... });
</code>
I obtain the following message : <br />

TypeError : str is undefined

<br />
at jquery.datatable.js at line 2567.<br />
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

oLang.sZeroRecords

at line 1499.<br />
I solve the problem by added the following code <br />
<code class='multiline brush: js;'>
else if ( sZero === undefined )
{
sZero = &quot;&quot;;
}
</code>
at line 1509.<br />
<br />
An other solution is to include the content of the translation directly in the js file I wrote like this :<br />
<code class='multiline brush: js;'>
$(&#039;#tableTicketsProcheSla&#039;).dataTable({
&quot;oLanguage&quot;: {
...the translation copy...
}, ... });
</code>
<br />
This error appear when I apply a filter on column (the last line).<br />
<br />
Maybe I don't use datatable correctly, if you have any idea why I obtain the undefined value whitout modification of datatable framework.<br />
<br />
My code :<br />
<code class='multiline brush: js;'>
function sortTableSla( userName )
{
var tableProcheSla = $(&#039;#tableTicketsProcheSla&#039;).dataTable({
&quot;oLanguage&quot;: {
&quot;sUrl&quot;:&quot;js/Frameworks/jquery/internationalisation/datatable_french.txt&quot;
},
&quot;aoColumnDefs&quot;: [
{ &quot;sWidth&quot;: &quot;50px&quot; , &quot;aTargets&quot;: [ 0 ] },
{ &quot;sWidth&quot;: &quot;350px&quot;, &quot;aTargets&quot;: [ 1 ] },
{ &quot;sWidth&quot;: &quot;100px&quot;, &quot;aTargets&quot;: [ 3 ] },
{ &quot;sWidth&quot;: &quot;100px&quot;, &quot;aTargets&quot;: [ 4 ] },
{ &quot;sWidth&quot;: &quot;100px&quot;, &quot;aTargets&quot;: [ 5 ] },
{ &quot;sWidth&quot;: &quot;170px&quot;, &quot;aTargets&quot;: [ 6 ] }
],
&quot;bStateSave&quot;: true,
&quot;iDisplayLength&quot;: 10,
&quot;bLengthChange&quot;: false,
&quot;bAutoWidth&quot;: false,
&quot;bDestroy&quot;: true,
&quot;aaSorting&quot;:[ [4,&#039;asc&#039;] ]
}).columnFilter({
sPlaceHolder: &quot;head:after&quot;,
aoColumns: [
{ type: &quot;text&quot; },
{ type: &quot;text&quot; },
{ type: &quot;select&quot; },
{ type: &quot;date-range&quot; },
{ type: &quot;date-range&quot; },
{ type: &quot;select&quot; },
{ type: &quot;select&quot; }
]

                });
var found = false;
$(&amp;#039;#tableTicketsProcheSla&amp;#039;).find(&amp;quot;select&amp;quot;).each(function( index ){
try{
$(this).find(&amp;quot;option&amp;quot;).filter(function(){
if( $(this).text() == userName ) found = true;
return $(this).text() == userName;
}).prop(&amp;#039;selected&amp;#039;, true);
}catch (e) {
console.log(e);
}
});

//

if( !found )
{
var divParent = $(&quot;#tableTicketsProcheSla&quot;).parent();
var newDiv = createDivForDataTable(&quot;tableTicketsProcheSla&quot;, userName, 2 );
divParent.append( newDiv );
}
tableProcheSla.fnFilter( userName, 2 );
}
</code>
<br />
Thanks for your help,<br />
Regards,<br />
Mathieu


Viewing all articles
Browse latest Browse all 1816

Trending Articles