[index.js]
dataBound(args){
this.gridInstance.getHeaderContent().append(this.gridInstance.getFooterContent());
} |
[index.js]
export class AggregateDefault extends SampleBase {
constructor() {
super(...arguments);
this.pageSettings = { pageCount: 5 };
}
footerSum(props) {
return (<span>Sum: {props.Custom}</span>);
}
. . . .
customAggregateFn(args){
let freight_total = 0; //Perform your custom aggregation here
for(let i=0; i<args.result.length;i++) {
freight_total += args.result[i].Freight;
}
return freight_total;
}
render() {
return (<div className='control-pane'>
<div className='control-section'>
<GridComponent ref={g=>this.gridInstance=g} dataSource={data} allowPaging={true} pageSettings={this.pageSettings} dataBound={this.dataBound.bind(this)}>
<ColumnsDirective>
. . . .
</ColumnsDirective>
<AggregatesDirective>
<AggregateDirective>
<AggregateColumnsDirective>
<AggregateColumnDirective field='Freight' type='Custom' format='C2' customAggregate={this.customAggregateFn.bind(this)} footerTemplate={this.footerSum}> </AggregateColumnDirective>
</AggregateColumnsDirective>
</AggregateDirective>
</AggregatesDirective>
<Inject services={[Page, Aggregate]}/>
</GridComponent>
|
customAggregateFn(args){
let freight_total = 0; //Perform your custom aggregation here
for(let i=0; i< this.gridInstance.dataSource.length; i++) { // complete data list
freight_total += this.gridInstance.dataSource[i].Freight;
}
return freight_total;
} |