jqxGrid
checkbox selectionmode with group aggregate
by Peerachat Uengpattanakit
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">
<div id="jqxgrid"></div>
JavaScript
var data = [
{ name: "Product 1", amount: 20, price: 5 },
{ name: "Product 1", amount: 15, price: 2 }
];
var source = {
localdata: data,
datatype: "array",
datafields: [
{ name: "name" },
{ name: "amount" },
{ name: "price" }
]
};
var dataAdapter = new $.jqx.dataAdapter(source);
$("#jqxgrid").jqxGrid({
theme: 'energyblue',
width: 500,
height: 350,
source: dataAdapter,
selectionmode: "checkbox",
groups: ["name"],
groupable: true,
showgroupaggregates: true,
groupsexpandedbydefault: true,
columns: [{
text: 'Name',
datafield: 'name',
width: 200
},
{
text: 'Amount',
datafield: 'amount',
width: 200,
aggregates: ['sum']
},
{
text: 'Price',
datafield: 'price',
width: 200
}
]
});