endRender of Rowgroup
endRender of Rowgroup
antoniocib
Posts: 277Questions: 62Answers: 1
in Editor
Good morning,
I use RowGroup's endRender to do some sums and it works fine, now I should output a value but I don't know how to display it I attach photos and code, I hope to explain myself better in this way.
endRender: function ( rows, group, level ) {
if ( level === 0 ) {
var intVal = function ( i ) {
return typeof i === 'string' ?
i.replace(/[\$,]/g, '')*1 :
typeof i === 'number' ?
i : 0;
};
var epal_tot = rows
.data()
.pluck('buono')
.pluck('n_bancali')
reduce( function (a, b) {
return intVal(a) + intVal(b);
}, 0) ;
var colore = 'verde';
return $('<tr/>')
.addClass(colore)
.append( '<td></td>' )
.append( '<td></td>' )
.append( '<td></td>' )
.append( '<td></td>' )
.append( '<td></td>' )
.append( '<td></td>' )
.append( '<td>EPAL:</td>' )
.append( '<td>'+epal_tot+'</td>' )
.append( '<td>Stipendio </td>' )
.append( '<td>'+prezzo_tot+'€</td>' )
.append( '<td>Nolo:</td>' )
.append( '<td>'+nolo_tot+'€</td>' )
;
}
In this code I just take a value and add it up.
Instead, in this other way I would like to display the data
var num_tot = rows
.data()
.pluck( 'buono' )
.pluck( 'autista' )
.unique();
the console.log of "num_tot" is this:
This question has an accepted answers - jump to answer
Answers
I think you can just use Javascript join() to join the array into a string that can be displayed in HTML. Something like this:
If you don't want separate lines you can replace
</br>
wit,
or whatever you want to separate the values.Kevin
Thanks @kthorngren works just with