Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
817 views
in Technique[技术] by (71.8m points)

jquery - JQGrid: Loading data into the footer row

Are there any examples for loading data into the footer? I can't find any or I'm being blocked at work.

Thanks in advance...

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...