Hello,
We have a dynamically created Grid for which we need to have an Excel Export. The code below returns an empty excel file (no data). What are we doing wrong?
// Parent file
import ClickTrackingGrid from './common/Grid';
import { ExcelExport } from '@progress/kendo-react-excel-export';
export default class EmailClients extends React.Component {
_export;
constructor(props) {
super(props);
this.export = this.export.bind(this);
}
export() {
this._export.save();
}
render() {
<button title="Export Excel" className="k-button k-primary" onClick={this.export}>Export to Excel</button>
<ExcelExport data={this.props.ctGeographGeoFigures} ref={(exporter) => { this._export = exporter; }}>
<ClickTrackingGrid dataSource={this.props.ctGeographGeoFigures} />
</ExcelExport>
}
}
// ClickTrackingGrid file
import React from 'react';
import { Grid, GridColumn } from '@progress/kendo-grid-react-wrapper';
export default class ClickTrackingGrid extends React.Component {
render(){
const { dataSource } = this.props;
var allColumns = dataSource.length > 0 ? Object.keys(dataSource[0]) : [];
var columnsToShow = allColumns.map((item,i) => <GridColumn field={item} key={i} />);
return (
<Grid dataSource={dataSource}>
{ columnsToShow }
</Grid>
);
}
}