jquery - Put specific data in jqgrid summary view header -
i have working jqgrid table has summary view on header, example implemented in this plunkr here http://plnkr.co/edit/wjilavmsa9vusmfhgfl1?p=preview.
the summary view header works fine, , data displayed comes (sum) function in jqgrid.
however, instead of letting jqgrid calculate summary itself, want display own data in summary row (and still per column, dont want colspan summary header). easiest example be: suppose data under columns text. still want have grouping & summary view header & show data per column on summary header, don't want jqgrid calculate summary me (since it's text). want display own summary data, comes data json.
i dont think using
summarytpl: '<b>{0}<b>' will work me since data want display comes json data.
is possible? let me know if explanation not clear enough. thank you!
the demo posted uses jqgrid 4.6 version. have not possibility set custom summary value in case. can use custom formatter in column need place custom summary value. described approach in the old answer. it's tricky.
alternatively can suggest use free jqgrid 4.8 (see readme , wiki). free jqgrid supports summarytype defined function. show how works created jsfiddle examples you. the first one consist original demo. the second one contains
summarytype: function (v, cn, record) { var fielddata = parseint(record[cn], 10); return v === "" ? fielddata : fielddata + v; } instead of summarytype: "sum". results in summary column close original one, used parseint(record[cn], 10) instead of parsefloat(record[cn]). integer part of input numbers , results integer too.
the next demo contains static variable
var mysummary = { alfki: 12, anatr: 23, arout: 34, bergs: 45, blaus: 56 }; and summarytype looks
summarytype: function (v, cn, record) { return mysummary[record.customerid]; } in way summary results every group displayed based on mysummary map. remind values formatted same formatter defined in column. because use formatter: 'number' in column freight, results should numbers or string can converted numbers.
the last demo uses modified json data
{ "userdata": { "alfki": 12.34, "anatr": 23.45, "arout": 34.56, "bergs": 45.67, "blaus": 56.78 }, "rows":[ .... ] } the summarytype defined
summarytype: function (v, cn, record) { var userdata = $(this).jqgrid("getgridparam", "userdata"); return userdata[record.customerid]; } as result values displayed in grouping summary come userdata part of server. think it's want.
Comments
Post a Comment