This online shopping cart example shows how to use grid built-in capabilities to
calculate aggregates.
- Notice that as you change quantity value or insert/delete a new order entry, the
aggregates on the bottom change
- You can setup through context which aggregates to calculate and for which columns.
- min,max,avg,sum and count rows use
built-in grid aggregate functions.
Code
var context = {
sequence:true,checkBox:true,readonly:false,sortable:false,
aggregate:[
{col:"quantity",exp:"sum",format:"#"},
{col:"price",exp:"sum",format:"#.00"},
],
paintMode:"all"
};
Online shopping cart
Tips
Aggregate objects in context are needed to tell Sigma Grid how to calculate aggregates.
Each Aggregate object has three attributes.
col - To specify calculate aggregate on which column.
exp - To specify calculate which aggregate. Counld be sum,avg,max,min and count.
format - To specify what format the aggregate result is displayed in.
|