Footer sum of a hh:mm:ss data type column

Footer sum of a hh:mm:ss data type column

muscaiumuscaiu Posts: 6Questions: 4Answers: 0

I can get the footer total of a INT column like this:

    footerCallback: function ( row, data, start, end, display ) {
                var quantita = this.api(), data;

                // Total quantita over all pages
                total_quantita = quantita
                    .column( 5 )
                    .data()
                    .reduce( function (a, b) {
                        return intVal(a) + intVal(b);
                    }, 0 ); 

                // Total quantita over this page
                pageTotal_quantita = quantita
                    .column( 5, { page: 'current'} )
                    .data()
                    .reduce( function (a, b) {
                        return intVal(a) + intVal(b);
                    }, 0 ); 

                // Update footer Column "quantita"
                $( quantita.column( 5 ).footer() ).html(
                pageTotal_quantita +' ('+ total_quantita +' total)'
                );

My question is: how can i get the total of a hh:mm:ss data type column like in this picture: https://goo.gl/Xuf4ip
Thank you!

This question has an accepted answers - jump to answer

Answers

  • jr42.gordonjr42.gordon Posts: 305Questions: 2Answers: 49

    The hh:mm:ss should just be the output format of that column's raw data. So you should be able to have your own functionality summing up the raw data for that column.

  • allanallan Posts: 63,552Questions: 1Answers: 10,477 Site admin
    Answer ✓

    Three methods I can think of:

    1. Use an integer value in the data source which makes summing it really easy as @js42.gordon suggests. You would need to add an output formatter (renderer) as well.
    2. Sum the values by converting the formatted string to an integer
    3. Use MomentJS to do the calculations for you.

    Allan

This discussion has been closed.