LigerUI - ligerGrid使用细节[2]

xiaoxiao2021-02-28  75

接上一篇LigerUI - ligerGrid使用细节[1]。

【9】totalSummary

列汇总:汇总类型sum,max,min,avg ,count,可以同时使用多种类型(即,进行多种属性汇总)。

示例一:使用type关键字

$(function () { $("#maingrid").ligerGrid({ columns: [ { display: '主键', name: 'ProductID', type: 'int', totalSummary: { type: 'count' } }, { display: '产品名', name: 'ProductName', align: 'left',width:200 }, { display: '单价', name: 'UnitPrice', align: 'right',type:'float', totalSummary: { type: 'sum,max' } }, { display: '仓库数量', name: 'UnitsInStock', align: 'right', type: 'float', totalSummary: { type: 'sum' } } ], isScroll: false, data: data, sortName: 'ProductID' }); });


示例二:使用render函数

{display:'星期日',name:'Sunday',align:'middle',width:'10%',type:'float', totalSummary:{ render: function (suminf, column, cell) { return suminf.avg.toFixed(2); } } },

这里注意suminf,column,cell三个参数。

如上图所示:

suminf : 汇总对象,其中属性分别有sum,count,avg,min,max;

column : 列对象,具体说明看上一篇;

cell : 与其说cell,更偏向于ligerGrid的数据集。{Total:XXX,Rows:YYY}形式。


转载请注明原文地址: https://www.6miu.com/read-76090.html

最新回复(0)