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

  • kthorngrenkthorngren Posts: 14,616Questions: 25Answers: 3,469
    Answer ✓

    You are in control of what HTML elements are returned. Currently you are building one tr in the container variable. You can add another tr for two rows.

    Kevin

  • EdaurdoCREdaurdoCR Posts: 2Questions: 1Answers: 0

    Thank you very much, I never thought that.

Sign In or Register to comment.