考勤界面, 列包含日期. 行的数据格式: 须要实现 编辑一列而后在最后产生的统计的效果.
行数据内容.
Gird Load 的时候统计数据:
-- 根据对象. 能够Ext.Date.parse 成功的都是日期列. 其余非日期列则不会执行统计.javascript
function AttenAllStaticsCalc() { for (var i = 0; i < AttendanceTable.store.data.items.length; i++) { var record = AttendanceTable.store.data.items[i]; var recordData = record.data; var staticQty = {}; for (var k in recordData) { var tm = Ext.Date.parse(k, 'Ymd') var recordDatas = recordData[k]; if (tm) { if (recordData[k]) { if (staticQty[recordData[k]] != undefined) { staticQty[recordData[k]] += 1; } else { staticQty[recordData[k]] = 1; } } } } var res = ""; if (staticQty) { for (var t in staticQty) { if (staticQty[t]) { var si = t + ": " + staticQty[t] + "; "; res += si; } } } if (res.length > 0) { res = res.substring(0, res.length - 2); } recordData['AttenStatics'] = res; //record.set("AttenStatics", res); //显示数据 } AttendanceTable.view.refresh(); }
每行编辑后设置统计数字; java
var staticQty = {}; for (var k in recordData) { var tm = Ext.Date.parse(k, 'Ymd') var recordDatas = recordData[k]; if (tm) { if (recordData[k]) { if (staticQty[recordData[k]] != undefined) { staticQty[recordData[k]] += 1; } else { staticQty[recordData[k]] = 1; } } } } //oldValue, newValue -1 + 1动做 staticQty[oldValue] = staticQty[oldValue] - 1; staticQty[newValue] = typeof(staticQty[newValue]) == 'undefined' ? 1 : staticQty[newValue] + 1; var res = ""; if (staticQty) { for (var t in staticQty) { if (staticQty[t]) { var si = t + ": " + staticQty[t] + "; "; res += si; } } } if (res.length > 0) { res = res.substring(0, res.length - 2); } record.set("AttenStatics", res); //显示数据
使用code