|
export class FilterMenu extends SampleBase {
constructor() {
super(...arguments);
this.indexVal = 0;
}
// Grid’s dataBound event handler
dataBound() {
// Global index variable value is set as ‘0’
this.indexVal = 0;
}
// Value accessor method
rowNumerCal(field, data, column) {
// Incremented index value is returned for each cell
return ++this.indexVal;
}
render() {
return (<div className='control-pane'>
<div className='control-section row'>
<GridComponent dataSource={orderDataSource} dataBound={this.dataBound.bind(this)} ...>
<ColumnsDirective>
<ColumnDirective headerText='Row number' width='80' textAlign="Right" valueAccessor={this.rowNumerCal.bind(this)} />
.
.
</ColumnsDirective>
<Inject services={[Filter, Page, Sort]} />
</GridComponent>
</div>
</div>);
}
}
render(<FilterMenu />, document.getElementById('sample')); |
|
const dataBound = () => {
indexValue = 1;
gridRef.current.contentModule.freezeRowElements.forEach( ele => {
ele.querySelector('.e-rowcell').innerText = indexValue;
++indexValue;
});
}; |
I implemented this with ref and it works in grid but when I am using this column in pdf or excel export, it doesn't show up.
Values are empty, column is shown but blank.
|
constructor() {
super(...arguments);
this.template = this.gridTemplate;
}
gridTemplate(props) {
// Here the index values will be returned in the arguments which can be used for setting row index values in columns
var index = props.index;
return (<div>{index}</div>);
}
render() {
return (<div className='control-pane'>
<div className='control-section'>
<div className='col-lg-8'>
<GridComponent dataSource={orderDetails} ...>
<ColumnsDirective>
<ColumnDirective headerText='Index' width='80' template={this.template} isFrozen={true} />
</ColumnsDirective>
</GridComponent>
</div>
</div>
</div>);
} |
|
// Grid’s toolbarClick event handler
toolbarClick(args) {
switch (args.item.text) {
case 'PDF Export':
// The global index variable is set as ‘0’ to start from initial row
this.index = 0;
this.grid.pdfExport();
break;
case 'Excel Export':
// The global index variable is set as ‘0’ to start from initial row
this.index = 0;
this.grid.excelExport();
break;
}
}
// Grid’s pdfQueryCellInfo and excelQueryCellInfo event handlers
exportQueryCellInfo(args) {
// Check if event is triggered for the index column
if (args.column.headerText === 'Index') {
// The global index value is set as the column value
args.value = this.index.toString();
// The global index value is incremented for the next row
this.index++;
}
} |