checkBox rendering fails if "language" section is declared in extended "$.fn.dataTable.defaults"
checkBox rendering fails if "language" section is declared in extended "$.fn.dataTable.defaults"
BjornHa
Posts: 85Questions: 18Answers: 0
in DataTables
Test case
https://live.datatables.net/gowuqazi/1/edit
In DT 3.1.4 when "language" section in "$.fn.dataTable.defaults" is commented out everything works.
When not this appears in the console:
"TypeError: Cannot read properties of undefined (reading 'rowCheckbox')
at s (https://cdn.datatables.net/v/bs5/jszip-3.10.1/dt-3.1.4/b-4.1.2/cv-1.1.2/date-2.1.2/e-3.1.1/fc-6.1.1/kt-3.1.1/rg-2.1.1/sc-3.1.1/sb-2.1.1/sp-3.0.0/sl-4.1.1/datatables.min.js:135:19513)
at Object.renderer (https://cdn.datatables.net/v/bs5/jszip-3.10.1/dt-3.1.4/b-4.1.2/cv-1.1.2/date-2.1.2/e-3.1.1/fc-6.1.1/kt-3.1.1/rg-2.1.1/sc-3.1.1/sb-2.1.1/sp-3.0.0/sl-4.1.1/datatables.min.js:30:8691)
at Cr.i.dataGet (https://cdn.datatables.net/v/bs5/jszip-3.10.1/dt-3.1.4/b-4.1.2/cv-1.1.2/date-2.1.2/e-3.1.1/fc-6.1.1/kt-
(rest of message cut out)
Not sure if I am missing something somewhere, but same language settings works fine with DT 2.3.4.
Test case contains settings for both 3.1.4 and 2.3.4
Language section is commented, activate section and 3.1.4 will fail.
KR,
Bjørn Hasselberg
This question has an accepted answers - jump to answer
Answers
Looking at the
selectlanguage options I foundlanguage.select.aria.rowCheckbox. Added that the theselect.languageconfig and it now works. For example:Looks like it needs to be added due to this comment in the
language.select.aria.rowCheckboxdocs.Updated test case:
https://live.datatables.net/gowuqazi/2/edit
You may also want to set
language.select.aria.headerCheckboxbut it doesn't seem to be required.Kevin
OK, as the language file is provided here
https://cdn.datatables.net/plug-ins/3.1.4/i18n/sv-SE.json
and the items you mention is not possible to set in the page (https://datatables.net/download/plug-ins/i18n/) where you can submit changes, I guess something needs to be added
Is the problem. You are doing a shallow copy, so any of the defaults which are in the library, but not in the translation JSON (as is the case here) is gets overwritten.
You need to do a deep extend:
Or without jQuery:
Updated test case: https://live.datatables.net/gowuqazi/4/edit .
Allan