Datatable 1.9 - defaults and language
Datatable 1.9 - defaults and language
Hi,
I try to use the 'Setting defaults' to set the 'oLanguage' option.
If I set the parameters by keywords it raises a JS error: A is undefined (see http://jsfiddle.net/matthias/hBnWt/)
If I set the parameter with the 'sUrl'... it's not formating at all :-( (see http://jsfiddle.net/matthias/b7huv/)
Without the parameter it's behaving normally (see http://jsfiddle.net/matthias/QLfmB/)
Help is very much appreciated...
BTW: great product... the beer will follow ;-)
Regards,
Matthias
I try to use the 'Setting defaults' to set the 'oLanguage' option.
If I set the parameters by keywords it raises a JS error: A is undefined (see http://jsfiddle.net/matthias/hBnWt/)
If I set the parameter with the 'sUrl'... it's not formating at all :-( (see http://jsfiddle.net/matthias/b7huv/)
Without the parameter it's behaving normally (see http://jsfiddle.net/matthias/QLfmB/)
Help is very much appreciated...
BTW: great product... the beer will follow ;-)
Regards,
Matthias
This discussion has been closed.
Replies
Thanks for posting a link to JS Fiddle with your test case - really useful!
The problem is this line:
[code]
$.extend( $.fn.dataTable.defaults, {
[/code]
It is only shallow copying - so in fact your oLanguage object is completely replacing the DataTables default one, and since your oLanguage object doesn't define every language option (the ARIA ones for example), then they aren't present in the language object DataTables sees.
So what you need to do is a deep copy:
[code]
$.extend( true, $.fn.dataTable.defaults, {
[/code]
and that will do the job :-)
Regards,
Allan
I'm having the same problem, even adding the "true" parameter it still doesn't work, the defaults are simply ignored.
Any help is appreciated, thank you!
[code]$.extend(true, $.fn.dataTable.defaults, {
"sPaginationType": "full_numbers" //IT'S IGNORED :( PAGINATION TYPE IS NOT APPLIED
});
[/code]
[code]
$("table.datatable").dataTable({
"bServerSide": true,
"sAjaxSource": '@Url.Action("GetGridData")',
"fnServerData": function (sSource, aoData, fnCallback) {
$.ajax({
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": fnCallback
});
},
"bLengthChange": false,
"aoColumns": [
{ "sName": "Id", "sType": 'numeric' },
{ "sName": "Name" }
]
});
[/code]
Wondering if setting defaults doesn't work in that version...
Allan