Hi Guys,
Table component has no direct feature of adding column totals as of this post written date(July 2nd 2013)....
Here is the pentaho community & data tables shared java script to find the Summation of columns in Table component.
Write below code in Draw Function of Table Component.
function f() {
var grandTotalRow = "<tfoot><tr><td>Total</td>";
for(i=1;i<4;i++) {
var total=0;
var rows = $('#' + this.htmlObject + ' tbody tr');
rows.each(function() {
var cellVal = parseFloat($('td:eq('+i+')', this).text().replace(',',''));
if(!isNaN(cellVal)){
total+=cellVal;
}
});
grandTotalRow += "<td>"+total.toFixed(2);+"</td>";
}
grandTotalRow += "</tr></tfoot>";
if($('#'+this.htmlObject+' tfoot').length===0)
$('#'+this.htmlObject).find('table').append(grandTotalRow);
}
Sample output:
References :
https://www.datatables.net/forums/discussion/17132/summary-footer-row
http://forums.pentaho.com/showthread.php?94187-Table-Component-Grand-total
Example :
https://metrics.mozilla.com/data/content/pentaho-cdf-dd/Render?solution=metrics2&path=%2FgetInvolved&file=getInvolved.wcdf
Table component has no direct feature of adding column totals as of this post written date(July 2nd 2013)....
Here is the pentaho community & data tables shared java script to find the Summation of columns in Table component.
Write below code in Draw Function of Table Component.
function f() {
var grandTotalRow = "<tfoot><tr><td>Total</td>";
for(i=1;i<4;i++) {
var total=0;
var rows = $('#' + this.htmlObject + ' tbody tr');
rows.each(function() {
var cellVal = parseFloat($('td:eq('+i+')', this).text().replace(',',''));
if(!isNaN(cellVal)){
total+=cellVal;
}
});
grandTotalRow += "<td>"+total.toFixed(2);+"</td>";
}
grandTotalRow += "</tr></tfoot>";
if($('#'+this.htmlObject+' tfoot').length===0)
$('#'+this.htmlObject).find('table').append(grandTotalRow);
}
Sample output:
References :
https://www.datatables.net/forums/discussion/17132/summary-footer-row
http://forums.pentaho.com/showthread.php?94187-Table-Component-Grand-total
Example :
https://metrics.mozilla.com/data/content/pentaho-cdf-dd/Render?solution=metrics2&path=%2FgetInvolved&file=getInvolved.wcdf
Thank you for the post. I have a doubt, Can you please help. I want to represent the number columns in indian notation. example: 1,20,000.00
ReplyDelete