EditGridPanel事件

需求: EditGridPanel 里面的 列 的值改变,则触发事件该列的相关指标也改变数据
在 EditGridPanel 下 加入监听:
   listeners : {
afteredit : function(e) {
if (e.originalValue != e.value) {
CalculateIndex(e);
}
}
}

计算函数:
function CalculateIndex(e) {
var indexCode = e.record.data['indexCode']
if ((indexCode == '') || (indexCode == null))
return;
if (indexCode.length <= 4)
return;
while (indexCode.length > 4) {
var parentCode = getParentCode(indexCode);
if (parentCode == '')
return;
var subCode;
var sumValue = 0;
var tempValue = 0;
for (var i = 1; i <= 99; i++) {
tempValue = 0;
if (i < 10) {
subCode = parentCode + "0" + i;
} else {
subCode = parentCode + "" + i;
}
var index = dataStore.find('indexCode', subCode);
if (index == -1)
continue;
var tempRecord = dataStore.getAt(index);
if (tempRecord != null || tempRecord != '') {
tempValue = tempRecord.get('value');
if (tempValue != null && tempValue != '') {
sumValue += tempValue;
}
}
}
var indexParent = dataStore.find('indexCode', parentCode);
if (indexParent == -1)
return;
dataStore.getAt(indexParent).set('value', sumValue);
indexCode = indexCode.substr(0, indexCode.length - 2);
}
}

function getParentCode(indexCode) {
if (indexCode >= 6) {
return indexCode.substr(0, indexCode.length - 2);
} else {
return "";
}
}

你可能感兴趣的:(ext,事件,editgridpanel)