JQGrid: Loading data into the footer row

Look at demo http://trirand.com/blog/jqgrid/jqgrid.html

and choose on the left tree “New in Version 3.5” and then “Summary Footer Row“.

In the example one set footerrow : true, userDataOnFooter : true option of the jqGrid. Then server add userdata block to the data sent back to jqGrid. You can read about userdata in http://www.trirand.com/jqgridwiki/doku.php?id=wiki:retrieving_data. If userdata block hat properties corresponds to the column names of the jqGrid, the data will be seen in the footer row.

If you need more information you should write which kind of data you use in jqGrid (JSON, XML, xmlstring, jsonstring, local and so on) and what kind of server do you use (PHP, ASP.NET MVC, WCF end so on).

UPDATED: If you use standard json mapping your data (no jsonReader option of jqGrid) from server look like

{ 
  total: "xxx", 
  page: "yyy", 
  records: "zzz",
  rows : [
    {id:"1", cell:["cell11", "cell12", "cell13"]},
    {id:"2", cell:["cell21", "cell22", "cell23"]},
      ...
  ]
}

So the data has no name of columns from colModel. If you have, for example, one column {name:’price’, …} inside of colModel and want to show total price in the last row of jqGid you should define footerrow: true, userDataOnFooter: true inside of the jqGrid options and your server should produce data like

{ 
  total: "xxx", 
  page: "yyy", 
  records: "zzz",
  rows : [
    {id:"1", cell:["cell11", "cell12", "cell13"]},
    {id:"2", cell:["cell21", "cell22", "cell23"]},
      ...
  ],
  userdata: {price:1240.00} 
}

If you use another jsonReader all stat unchanged. The only which you can define is to change “userdata” name to another name, but the value must be an object with the field name like you defined in colModel. Only values of this fields will be shown fat on the last row of jqGrid.

Leave a Comment