Problems when configuring language.decimal in defaults / lack of "num,-pre" formatter

Problems when configuring language.decimal in defaults / lack of "num,-pre" formatter

spossnerspossner Posts: 1Questions: 1Answers: 0

Hi all,

in good old germany we also use comma as decimal (and dot as thousands) separator and I am using datables to sort revenues like 1.293,45 (which is 1293.45 in float).
After using custom formatters and custom detection I finally found the manual entry to use language: { decimal: "," .. } which works perfectly - if specified in the $('.table').dataTable({..}); init call.
Because I want to use it all over the site I thought it's a good idea to set it globally with

$.extend( true, $.fn.dataTable.defaults, {
    pageLength: 25,
    order: [],
    language: {
        decimal: ",",
        thousands: ".",
        url: "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
    }
});

But that does not work.

After debugging it seems to be, that a special column type num, (instead of num) is used. When it comes to sorting, the corresponding num,-pre formatter seems not to be generated – or stored correctly.
var formatter = DataTable.ext.type.order[ column.sType+"-pre" ];
in _fnSortData evaluates to undefined.

Am I doing something wrong with my global default settings or is decimal not ready to be controlled via global default setting due to a missing "generate the special decimal num-types"?

As mentioned: works perfectly when decimal is given in the dataTable init call like

$(document).ready(function() {
        $('.table').dataTable({
            language: {
                decimal: ",",
                thousands: ".",
                url: "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/German.json"
            }
    });
});

Thanks
Sebastian

Sign In or Register to comment.