Hi,
Starting from "Automatically update the column based on another column edited value in Batch mode" topic from Grid documentation, i want to do something that include also aggregate functionality.
i put the code into an archive file.
Aurelian, software developer @General Electric.
|
//Consumption
this.consumptionParams = {
create: () => {
this.consumptionElem = document.createElement('input');
return this.consumptionElem;
},
read: () => {
return this.consumptionObj.value;
},
destroy: () => {
this.consumptionObj.destroy();
},
write: (args) => {
var rowData = args.rowData;
var rowIndex = this.grid.getRowInfo(args.row).rowIndex;
this.consumptionObj = new NumericTextBox({
value: args.rowData[args.column.field],
change: function (args) {
let consumtionSum = (this.grid.aggregateModule as any)
.footerRenderer.aggregates.aggregates['ConsumptionTSO - sum'];
let generationSum = (this.grid.aggregateModule as any)
.footerRenderer.aggregates.aggregates['GenerationTSO - sum'];
var share = this.shareCalculation(
args.value,
rowData['ConsumptionTSO'],
consumtionSum,
generationSum
);
//var share = ((rowData['ConsumptionTSO'] + args.value) / (consumtionSum + generationSum)) * 100;
//let share = args.value * rowData['ConsumptionTSO'];
console.log('consumtionSum : ', consumtionSum);
console.log('generationSum : ', generationSum);
console.log('share : ', share);
this.grid.setCellValue(rowData['Area'], 'Share', share);
}.bind(this),
});
this.consumptionObj.appendTo(this.consumptionElem);
},
|