rowGroup endRender multiple Rows

rowGroup endRender multiple Rows

EdaurdoCREdaurdoCR Posts: 2Questions: 1Answers: 0

Can you add two rows at the end?, since it only returns only one and I occupy two.

rowGroup: {endRender: function(rows, group) {

                        var intVal = function(i) {
                            return typeof i === 'string' ?
                                i.replace(/[\$,]/g, '') * 1 :
                                typeof i === 'number' ?
                                i : 0;
                        };

                        var column = [6, 7, 8, 9];

                        var api = rows,
                            data;

                        var numero = $.fn.dataTable.render.number(',', '.', 2).display;

                        var container = $('<tr/>');
                        container.append('<td colspan="6" style="text-align:right;">Total en pesos</td>');


                        _.each(column, function(idx) {

                            var totalPesos = api
                                .column(idx)
                                .data()
                                .reduce(function(a, b) {

                                    var cur_index = api.column(idx).data().indexOf(b);
                                    if (api.column(5).data()[cur_index] != "Dolares") {
                                        return intVal(a) + intVal(b);
                                    } else {
                                        return intVal(a);
                                    }
                                }, 0)


                            container.append('<td>' + numero(totalPesos) + '</td>');

                        })
                        container.append('<td colspan="6" style="text-align:right;">Total en dolares</td>');
                        _.each(column, function(idx) {

                            var totalDolares = api
                                .column(idx)
                                .data()
                                .reduce(function(a, b) {

                                    var cur_index = api.column(idx).data().indexOf(b);
                                    if (api.column(5).data()[cur_index] != "Pesos") {
                                        return intVal(a) + intVal(b);
                                    } else {
                                        return intVal(a);
                                    }
                                }, 0)


                            container.append('<td>' + numero(totalDolares) + '</td>');

                        })

                        return $(container)



                    },
                    dataSrc: 'estado'
                }

This question has an accepted answers - jump to answer

Answers

Sign In or Register to comment.