0

I am using jqGrid and displaying my data in grid I have 5 columns. I want to calculate SUM of each column and display the sum at the end of the column , probably in the footer.![In the below image, the TOTAL is displayed only for Amount col, I want it to be displayed for all the columns at the end of the column Click here for the image

Pavy
  • 111
  • 1
  • 11

1 Answers1

0

You can achieve this, using LoadComplete - function

To show sum of Amount column as Total in the footer of the grid, then you should enable footerrow and you should use loadComplete function like below,

footerrow: true,
loadComplete: function () {
       var sumOfPrice = jQuery("#gridId").jqGrid('getCol','Amount',false,'sum');           
       jQuery("#gridId").jqGrid('footerData', 'set', { Date: 'Total:', Amount: sumOfPrice });                     
}

For more info regrading loadComplete function, have a look over here.

Community
  • 1
  • 1
prakash2089
  • 498
  • 4
  • 16
  • jQuery("#gridId").jqGrid('footerData', 'set', { Date: 'Total:', Amount: sumOfPrice }); In the above line , cant we make the colName (Ex: Date and AMmount ) to be dynamic, like taking these from an array ?? – Pavy Apr 25 '14 at 04:21
  • 1
    I used gridComplete instead of loadComplete.. referred from other stackoverflow link – Pavy Apr 25 '14 at 04:23