2

hi i want to calculate the sum of column in my jqgrid "column montant" and display it under my grid like Total : **** under Montant column here is my grid :

<sjg:grid id="gridtable"
        caption="Quittance PayƩe"
        dataType="json"
        width="755"
        href="%{remoteurl}"
        pager="true"
        gridModel="gridModel"
        rowList="5,10,15,20"
        rowNum="5"
        rownumbers="true"

        >

    <sjg:gridColumn name="entreprise" index="entreprise" title="Entreprise"/>
    <sjg:gridColumn name="nature" index="nature" title="Nature" sortable="false"/>
    <sjg:gridColumn name="numero" index="numero" title="Numero" sortable="false"/>
    <sjg:gridColumn name="montant" index="montant" title="Montant" sortable="false"/>

</sjg:grid>

any ideas :)

djoStack
  • 177
  • 3
  • 18

1 Answers1

0

On the latest version of jqGrid, you can do this:

This is done via the magic of the getCol method.

Initialize a variable that would hold the sum:

var sum = jQuery("#gridtable").getCol('montant', false, sum);

And it's done. The sum variable now has the sum of the column 'montant'. For more information on the other parameters of the getCol method, go here.

Alec Gerona
  • 2,806
  • 1
  • 24
  • 24