Formatted numbers with $.fn.dataTable.render.number are not negative anymore

Formatted numbers with $.fn.dataTable.render.number are not negative anymore

FlouxFloux Posts: 3Questions: 0Answers: 0
edited September 2015 in Free community support

Hi,

I do not know if I missed something or if this is a bug but when I format numbers with $.fn.dataTable.render.number the negative symbol "-" disappears.

Here my table configuration :

campagnes.DataTable({
    data: dataSet,
    deferRender: true,
    fixedHeader: true,
    columnDefs: [
        {targets: 7, render: $.fn.dataTable.render.number( ' ', ',', 2, '', ' €' ) },
        {targets: [5,6], render: $.fn.dataTable.render.number( ' ', ',', 0, '', ' €' ) },
        {targets: [3,4,5,6,7], className: 'text-right'},
        {targets: [1,8,9,10], className: 'text-left'}
    ]
});

Thanks for your help !

Replies

  • allanallan Posts: 61,950Questions: 1Answers: 10,158 Site admin

    Can you link to the page showing the issue please.

    Allan

  • FlouxFloux Posts: 3Questions: 0Answers: 0

    Thanks for your fast reply, here is a static copy of the page where the problem occurs :

    http://foulquesdupeloux.no-ip.org/datatable/

  • allanallan Posts: 61,950Questions: 1Answers: 10,158 Site admin

    I think the issue might be that you aren't actually passing a number into the formatter - but rather a string like "-3406 €",. Why pass that through the formatter - it is already formatted?

    Allan

  • FlouxFloux Posts: 3Questions: 0Answers: 0

    Thanks you were right, I deleted '€' symbols from the data source to have real numbers and it worked.

This discussion has been closed.