Globally change default oLanguage
Globally change default oLanguage
I'm trying to globally change the filtering info for all datatable instances without having to edit each one.
I was trying this:
[code]
$.extend( $.fn.dataTable.defaults, {
"oLanguage": {
"sInfoFiltered": "(filtered from _MAX_ total entries)"
}
});
[/code]
but I can't seem to get it to work...
Any thoughts?
Dave
I was trying this:
[code]
$.extend( $.fn.dataTable.defaults, {
"oLanguage": {
"sInfoFiltered": "(filtered from _MAX_ total entries)"
}
});
[/code]
but I can't seem to get it to work...
Any thoughts?
Dave
This discussion has been closed.
Replies
I found that placing this code in my main page does the trick. Any reason why I shouldn't use this?
[code]
$.fn.dataTable.defaults.oLanguage.sInfoFiltered = "";
[/code]
Thanks,
Dave
No reason why you shouldn't use the second one. The reason the first one doesn't work is that $.extend is shallow by default, so you are replacing all of `oLanguage` in the defaults with the object you define there (i.e. it removes all the other strings)!. You would need a deep copy:
[code]
$.extend( true, $.fn.dataTable.defaults, {
"oLanguage": {
"sInfoFiltered": "(filtered from _MAX_ total entries)"
}
});
[/code]
Allan