1

while selecting the checkbox in the jqgrid i need to sum the values of row data in jqgrid and i need to display those data in the footer of the jqgrid.Please help me out how to achieve that.

Thanks in Advance, Silambarasan,

simbu94
  • 1,012
  • 2
  • 10
  • 22

2 Answers2

1

You can use footerData method. See here and here for details and demo examples.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
1

I got the answer ,i solved that issue.

The Answer is.

footerrow:true, userDataOnFooter:true, onSelectRow: function(rowId) { handleSelectedRow(rowId); },

function handleSelectedRow(id) {

        var jqgcell     = jQuery('#list1').getCell(id, 'headerId');
        var amount     = jQuery('#list1').getCell(id, 'amount');            
        var cbIsChecked = (jQuery("#jqg_list1_"+jqgcell).attr('checked'));
     if(cbIsChecked==true)
         {

            if(amount!=null)
                {
                    totalAmt = parseInt(totalAmt) + parseInt(amount);
                }
         }else
             {
             if(amount!=null)
                {
                    totalAmt = parseInt(totalAmt) - parseInt(amount);
                }
             }

            myGrid.jqGrid('footerData','set',{needbydate:'Total Amount:',amount:totalAmt});

        }

The above function is used to get the values of the selected row by clicking the checkbox you will get the value from that by calling the external function like "handleSelectedRow" you pass your row object from that you do your operation and finally update your answer by using the jqGrid function like "myGrid.jqGrid('footerData','set',{needbydate:'Total Amount:',amount:totalAmt}); " It will update in your footer.I have attached the screenshot regarding this question for your reference.

Screenshot of the Onselect row sum in Footer Example.

simbu94
  • 1,012
  • 2
  • 10
  • 22
  • This is the example regarding the JQGrid on selecting the checkbox the value of the particular rows will get summed and displayed in footer in jQGrid. – simbu94 Jun 16 '11 at 12:27