jQWidgets Forums
jQuery UI Widgets › Forums › Grid › How to get average value.
Tagged: average value
This topic contains 4 replies, has 2 voices, and was last updated by Mpod Schuzatcky 10 years ago.
-
Author
-
Hi Mates,
I’ve edited some codeigniter code, there is view that show data in grid using jqgrid. like picture below.
And here the code to show sum value :{
text: ‘Akurasi Stok WIP Keramik’,
align: ‘center’,
datafield: ‘akurasi’,
filterable: false,
cellsformat: ‘n’,
cellsalign: ‘right’,
width: 120,
aggregates: [
{
‘total’: function (aggregatedValue, currentValue, column, record) {
return aggregatedValue + currentValue;
}
},
],
aggregatesrenderer: function (aggregates, column, element, summaryData) {
var renderstring = “<div style=’padding:5px’>”;
var total = aggregates.total;
renderstring += total;
renderstring += “</div>”;
return renderstring;
}
},The questions is, how to get average value? because im not familiar with jqgrid.
Thanks, Fadli.
Hi mpod555,
Thank you for your interest in jqxGrid. Take a look at the provided example at: http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/aggregatesrenderer.htm?arctic If you have any further questions do not hesitate to contact us.
Best Wishes,
MariyajQWidgets Team
http://www.jqwidgets.comThanx for fast respons.
I’ve seen the demo before, but still confused how to combine in this code below.{
text: ‘Akurasi Stok WIP Keramik’,
align: ‘center’,
datafield: ‘akurasi’,
filterable: false,
cellsformat: ‘n’,
cellsalign: ‘right’,
width: 120,
aggregates: [
{
‘total’: function (aggregatedValue, currentValue, column, record) {
return aggregatedValue + currentValue;
}
},
],
aggregatesrenderer: function (aggregates, column, element, summaryData) {
var renderstring = “<div style=’padding:5px’>”;
var total = aggregates.total;
renderstring += total;
renderstring += “</div>”;
return renderstring;
}
},can u help how to add code (what i must add) to get average value replace sum value.
Hi mpod555,
Can you please provide us with an example using jsFiddle?
Best Wishes,
MariyajQWidgets Team
http://www.jqwidgets.com[SOLVED]
Finally, i get what i need, thnx Mariya for your inspired reply…. nice to meet u btw…
I’m modified some code here :
{
text: ‘Akurasi Stok WIP Keramik’,
align: ‘center’,
datafield: ‘akurasi’,
filterable: false,
cellsalign: ‘right’,
width: 120,
aggregates: [‘avg’],
aggregatesrenderer: function (aggregates, column, element, summaryData) {
var renderstring = “<div style=’padding:5px’>Rerata: “;
var total = aggregates.avg;
renderstring += total.toFixed(2);;
renderstring += ” %</div>”;
return renderstring;
}
},Note : How to closed this thread as closed / solved?
-
AuthorPosts
You must be logged in to reply to this topic.