Datatables render body and footer column as numeric

Datatables render body and footer column as numeric

davidmenesesvdavidmenesesv Posts: 2Questions: 2Answers: 0
edited December 2017 in Free community support

I'm trying to format numeric data from a single column on the body and footer section. The formatting is as follows:

  • Thousands grouping separator: "."
  • Decimal point indicator: ","
  • Number of decimal points to show: "0"
  • Prefix: "$"

This is my try:

    $('#idtablainforme_ventaporfamilia').DataTable({
        destroy: true,
        "searching": false, "paging": false, "ordering": false, "info": false, "autowidth": false,
        columns: [
           { data: "1", render: $.fn.dataTable.render.text() },
           { data: "2", render: $.fn.dataTable.render.number('.', ',', 0, '$') }
        ],
        dom: 'Bfrtip',
        buttons: [
            {
                extend: 'excel',
                footer: true,
                title: 'INFORME DE VENTAS POR FAMILIA',
                text: '<i class="fa fa-file-excel-o"></i>',
                titleAttr: 'Exporta a EXCEL',
            }
        ]
    });

This is the data:

CHEQUERA MUJER 5231760 
CARTERA 3487630 
BILLETERA MUJER 2155120 
NECESER 21980 
COSMETIQUERA 10990 
SET DE VIAJE 10990
TOTAL 12925150

But it renders the following table:

<table id="idtablainforme_ventaporfamilia" class="table table-striped table-striped table-bordered nowrap dataTable">
    <thead>
        <tr role="row">
            <th>
                FAMILIA
            </th>
            <th>
                VENTA
            </th>
        </tr>
    </thead>
    <tfoot>
        <tr>
            <th>
                TOTAL
            </th>
            <th style="text-align: right">
                12.925.150
            </th>
        </tr>
    </tfoot>
    <tbody>
        <tr>
            <td>CHEQUERA MUJER</td>
            <td>$5</td>
        </tr>
        <tr>
            <td>CARTERA</td>
            <td>$5</td>
        </tr>
        <tr>
            <td>BILLETERA MUJER</td>
            <td>$2</td>
        </tr>
        <tr>
            <td>NECESER</td>
            <td>$21</td>
        </tr>
        <tr>
            <td>COSMETIQUERA</td>
            <td>$10</td>
        </tr>
        <tr>
            <td>SET DE VIAJE</td>
            <td>$10</td>
        </tr>
    </tbody>
</table>

The problem is that the formatting on the body section is wrong ($5 instead of $5.231.760) and it doesn't format the footer section.

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Can you link to a page showing the issue so I can debug it please?

    Allan

This discussion has been closed.