先看下extjs grid实现合计功能效果:
实现方法也很简单,先看代码:
xtype:"grid", features: [{ ftype: 'summary', dock: 'bottom' }], columns:[{ text: '大货款号', dataIndex: 'productCode', width:100, summaryRenderer: function(value, summaryData, dataIndex) { return "<span style='font-weight: bold'>合计:</span>"; } },{ text:"品牌", dataIndex:"brandName", width:100 },{ text:"产品下单号", dataIndex:"code", width:100 },{ text:"颜色", dataIndex:"colorName", width:80 },{ text:"尺码", dataIndex:"sizeName", width:80 },{ text:"SKU", dataIndex:"skuCode", width:100 },{ text:"订单数量", dataIndex:"produceNum", width:80, summaryType: 'sum', summaryRenderer: function(value, summaryData, dataIndex) { return "<span style='font-weight: bold'>"+value+"</span>"; } },{ text:"单价", dataIndex:"producePrice", width:80 },{ text:"金额", dataIndex:"money", width:80, summaryType: 'sum', summaryRenderer: function(value, summaryData, dataIndex) { return "<span style='font-weight: bold'>"+value+"</span>"; } }] }]
代码说明:
1.首先grid 加上代码如下
features: [{
ftype: 'summary',
dock: 'bottom'
}],
2.column需要统计的列加上代码如下
summaryType: 'sum',到这里就可以了
summaryRenderer只不过用来加了一下粗体文字
另外还有很多种统计方式 summaryType: 'max', 'average', function(records, values)