日期:2014-05-16 浏览次数:20732 次
this.store = new Ext.data.JsonStore({ url : "/work/listWork.do", root : "result", totalProperty : "totalCounts", remoteSort : true, idProperty : "userId",//通过两张表相同字段筛选唯一记录 fields : [{ name : "workId",//work表主键字段 type : "int" }, "user"]//user表 });
app.ux.AggregateStore=Ext.extend(Ext.data.GroupingStore,{ summaryField:null, constructor:function(config){ Ext.apply(this,config); app.ux.AggregateStore.superclass.constructor.call(this); this.on('load',this.aggregate,this); }, aggregate:function(){ var rec=null; this.each(function(record){ if(rec==null||rec.data[this.groupField]!=record.data[this.groupField]){ /////针对特定项目的处理 if(record.data.salePrice==undefined||record.data.salePrice==0){ record.data.salePrice=record.data.price; } record.data.profit=(record.data.salePrice-record.data.price)*record.data.quantity; //////////通用代码 rec=record; return; } if(rec.data[this.groupField]==record.data[this.groupField]){ /////针对特定项目的处理 var currentTotal=record.data.total; record.data.profit=(record.data.salePrice-record.data.price)*record.data.quantity; record.data.profit+=rec.data.profit; record.data[this.summaryField]+=rec.data[this.summaryField]; record.data.quantity+=rec.data.quantity; /////////////通用代码 this.remove(rec); rec=record; } },this);