|
<div class="control-section">
<ejs-grid #grid [dataSource]='data' id="grid" allowPaging='true' (actionComplete)="actionComplete($event)" [pageSettings]='pageSettings' [editSettings]='editSettings' [toolbar]='toolbar'>
<e-columns>
. . .
<e-column field='Freight' headerText='Freight' width='120' format='C2' textAlign='Right'></e-column>
. . .
</e-columns>
<e-aggregates>
<e-aggregate>
<e-columns>
<e-column type="Sum" field="Freight" format="C2">
<ng-template #footerTemplate let-data>Sum: {{data.Sum}}</ng-template>
</e-column>
</e-columns>
</e-aggregate>
</e-aggregates>
</ejs-grid>
</div> |
|
export class AppComponent {
public data: Object[];
public editSettings: Object;
public toolbar: string[];
public orderidrules: Object;
public customeridrules: Object;
@ViewChild('grid', {static: true})
public grid: GridComponent;
public ngOnInit(): void {
. . .
}
actionComplete (args) {
if (args.requestType === 'beginEdit' || args.requestType === 'add') {
// here we are binding the onChange event for the textbox
var inputEle = args.form.querySelector('#grid'+'Freight');
inputEle.onchange = this.updateAggregates.bind(this);
}
}
updateAggregates (args) {
var form = parentsUntil(args.target, 'e-gridform');
var data = this.grid.editModule.getCurrentEditedData(form, {});
// here we are refreshing the aggregates with updated data
this.grid.aggregateModule.refresh(data);
}
} |