How to calculate column amount and show on FooterRow in Jqgrid in Asp.net

Hi guys! I displayed the data in jqgrid and included "footerrow: true" in jqgrid Now, according to my need, I want to show the sum of a specific column in the footer ... Plz guys Help me, as I use Jqgrid for the first time ...

Thanks in advance....

+5
source share
1 answer

If you want to sum the values ​​that are in jqGrid, you can do this in JavaScript (preferably in an event gridComplete):

$('#gridId').jqGrid({
    ...
    footerrow: true,
    gridComplete: function() {
        var $grid = $('#gridId');
        var colSum = $grid.jqGrid('getCol', '<Your column name>', false, 'sum');
        $grid.jqGrid('footerData', 'set', { 'Your column name>: colSum });
    }
});

If you need to calculate the amount on the server side, you must first enable the parameter userDataOnFooter:

$('#gridId').jqGrid({
    ...
    footerrow : true,
    userDataOnFooter : true
});

Then specify the amount in the server response. For example, in JSON, it should look like this:

{
    total: x,
    page: y,
    records: z,
    rows : [
        ...
    ],
    userdata: { <Your column name>: <sum counted on server side> }
}

jqGrid Demos ( " 3.5", " " ).

+14

All Articles