Hello Guys,
In this post i would like to explain grand total in the table component.
Solution :
function() {
var grandTotalRow = "<tfoot><tr><td>Total</td>";
for(i=1;i<3;i++) {
var total=0;
var rows = $('#' + this.htmlObject + ' tbody tr');
rows.each(function() {
var cellVal = parseFloat($('td:eq('+i+')', this).text().replace(',',''));
total += cellVal;
});
grandTotalRow += "<td>"+ total.toFixed(2);+"</td>";
}
grandTotalRow += "</tr></tfoot>";
if($('#'+this.htmlObject+' tfoot').length==0)
$('#'+this.htmlObject).find('table').append(grandTotalRow);
}
Note:
1) 3: Represents for numCols change as per your requirements.
2) total.toFixed(2):Fixed for up to 2 decimal
Reference :
http://forums.pentaho.com/showthread.php?94187-Table-Component-Grand-total
Hope this post helps someone and feel free to give comments and suggestion
Sumit Bansal
BI Developer
In this post i would like to explain grand total in the table component.
Solution :
function() {
var grandTotalRow = "<tfoot><tr><td>Total</td>";
for(i=1;i<3;i++) {
var total=0;
var rows = $('#' + this.htmlObject + ' tbody tr');
rows.each(function() {
var cellVal = parseFloat($('td:eq('+i+')', this).text().replace(',',''));
total += cellVal;
});
grandTotalRow += "<td>"+ total.toFixed(2);+"</td>";
}
grandTotalRow += "</tr></tfoot>";
if($('#'+this.htmlObject+' tfoot').length==0)
$('#'+this.htmlObject).find('table').append(grandTotalRow);
}
Note:
1) 3: Represents for numCols change as per your requirements.
2) total.toFixed(2):Fixed for up to 2 decimal
Reference :
http://forums.pentaho.com/showthread.php?94187-Table-Component-Grand-total
Hope this post helps someone and feel free to give comments and suggestion
Sumit Bansal
BI Developer
Find group totals .. that will be helpful
ReplyDeletecan you please share any example so that i can try on that ..and what else you have tried already tell me that also..
Delete