日期:2014-05-16 浏览次数:20328 次
1、直接在客户端统计,动态的修改Grid
?
2、代码如下
buttons: [{ text: '查询', handler: function() { var a = Ext.getCmp('wholesale-query-form').form.getValues(); var s = Ext.StoreMgr.lookup('wholesaleReportStore'); s.load({ params:a, callback:function(r,options,success){ if(!success){ alert("数据加载失败!"); } else{ //合计行 var sumc = 0; //数量合计 var sumw = 0; //重量合计 var suma = 0; //总金额合计 var avgp = 0; //平均价合计 var wgrid = Ext.getCmp("wholesale-report-grid") wgrid.store.each(function(record){ sumc += Number(record.data.scount); sumw += Number(record.data.sweight); suma += Number(record.data.samount); }); avgp = (suma/sumw).toFixed(2); var n = wgrid.getStore().getCount();// 获得总行数 var p = new Ext.data.Record({ salerName: '总计:', scount:sumc, sweight:sumw, samount:suma, aprice:avgp }); wgrid.store.insert(n, p);// 插入到最后一行 } } }); } }]
?