Html Grid
Invoke the renderaggregates method of the jqxGrid.
Author: http://jqwidgets.com
by Hristo Hristov
HTML
<script src="https://jqwidgets.com/public/jqwidgets/jqx-all.js"></script>
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://jqwidgets.com/public/jqwidgets/styles/jqx.energyblue.css">
<script src="https://jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/generatedata.js"></script>
<div id='jqxWidget'>
<div id="jqxgrid"></div>
</div>
<div style="margin-top: 10px;">
<input id="button" type="button" value=" Invoke the renderaggregates method" />
</div>
JavaScript
var data = generatedata(200);
var source = {
localdata: data,
datatype: "array",
datafields: [{
name: 'firstname',
type: 'string'
}, {
name: 'lastname',
type: 'string'
}, {
name: 'productname',
type: 'string'
}, {
name: 'available',
type: 'bool'
}, {
name: 'quantity',
type: 'number'
}, {
name: 'price',
type: 'number'
}],
updaterow: function (rowid, rowdata) {
// synchronize with the server - send update command
}
};
var dataAdapter = new $.jqx.dataAdapter(source);
// initialize jqxGrid
$("#jqxgrid").jqxGrid({
width: 700,
source: dataAdapter,
theme:'energyblue',
showstatusbar: true,
statusbarheight: 50,
editable: true,
showaggregates: true,
selectionmode: 'singlecell',
ready: function () {
var cells = $('#jqxgrid').find('.jqx-grid-cell-pinned');
var innerAggregateChildren = cells[3].childNodes;
innerAggregateChildren[0].style.color = 'red';
innerAggregateChildren[1].style.color = 'blue';
},
columns: [{
text: 'First Name',
columntype: 'textbox',
datafield: 'firstname',
width: 90
}, {
text: 'Last Name',
datafield: 'lastname',
columntype: 'textbox',
width: 90
}, {
text: 'Product',
datafield: 'productname',
width: 170,
aggregates: ['count', {
'Cappuccino Items': function (aggregatedValue, currentValue) {
if (currentValue == "Cappuccino") {
return aggregatedValue + 1;
}
return aggregatedValue;
}
}]
}, {
text: 'In Stock',
datafield:...