export class Grouping extends SampleBase {
constructor() {
super(...arguments);
this.groupOptions = { showGroupedColumn: false, columns: ['Country'],captionTemplate: this.gridTemplate };
}
gridTemplate(props) {
if(props.count ==1){
return (
<span>{props.key} - {props.count} item</span>
);
}else{
return (
<span>{props.key} - {props.count} items</span>
);
}
}
render() {
return (<div className='control-pane'>
<div className='control-section'>
<GridComponent dataSource={inventoryData} allowPaging={true} ref={grid => this.gridInstance = grid} pageSettings={{ pageCount: 5 }} allowGrouping={true} groupSettings={this.groupOptions} allowSorting={true} height="320" >
<ColumnsDirective>
<ColumnDirective field='Inventor' headerText='Inventor Name' width='180'></ColumnDirective>
. . .
</ColumnsDirective>
<Inject services={[Page, Group, Sort]}/>
</GridComponent>
</div>);
}
} |