Hi, I have grouped two column  and showing the total price  against the grouped column . How can I f

Hi, I have grouped two column  and showing the total price  against the grouped column . How can I f

polachanpolachan Posts: 101Questions: 50Answers: 0
edited January 2020 in Free community support

I want to add currency sign and format with two decimal places for the grouped column Please help
rowGroup: {
dataSrc: ["DepotName", "EmpName"], /
startRender: function (rows, group,level) {

                    var total = rows
                        .data()
                        .pluck("Total")
                        .reduce(function (a, b) {
                            return a + b;
                        });

                    return $('<tr/>')
                        .append('<td class="td-left" >' + group + '</td>')   .append('<td></td>')  
                         .append('<td></td>')
                         .append('<td></td>')
                         .append('<td></td>')
                         .append('<td></td>')
                         .append('<td></td>')
                         .append('<td style="font-weight:bold;text-align: right;"> </td>')  // How can I add two decimal places in front of the value with currency sign £ against the grouped total column
                    .append('<td style="font-weight:bold">' + total + '</td>');

            }
        },

Answers

  • rf1234rf1234 Posts: 3,021Questions: 88Answers: 421

    Here you are:
    https://datatables.net/manual/data/renderers#Built-in-helpers

    Here is an example from my own coding. Depending on the language I render numbers differently:

    if (lang == 'de') {
        numberRenderer = $.fn.dataTable.render.number( '.', ',', 2 ).display;
    } else {
        numberRenderer = $.fn.dataTable.render.number( ',', '.', 2 ).display;
    }
    ....
    data.cashflowAccum = numberRenderer(accum);
    
  • polachanpolachan Posts: 101Questions: 50Answers: 0

    Please can you help me how to add in my code
    return $('<tr/>')
    .append('<td class="td-left" >' + group + '</td>') .append('<td></td>')
    .append('<td></td>')
    .append('<td></td>')
    .append('<td></td>')
    .append('<td></td>')
    .append('<td></td>')
    .append('<td style="font-weight:bold;text-align: right;"> </td>') // How can I add two decimal places in front of the value with currency sign £ against the grouped total column
    .append('<td style="font-weight:bold">' + total + '</td>');

  • rf1234rf1234 Posts: 3,021Questions: 88Answers: 421

    Sorry, no, because I have no idea what you are doing there. Somebody else?

  • David@QuantumDavid@Quantum Posts: 36Questions: 4Answers: 2

    That is without a doubt the weirdest concatenation I have ever seen.

    @rf1234 my best guess is that as per their second post asking this question today: here, they want to add a $0.00 format value to the row group header as detailed here.

    But honestly, my guess is as good as the next guy's.

This discussion has been closed.