This is a migrated thread and some comments may be shown as answers.

Excel Export on dynamically created Grid

6 Answers 468 Views
Wrappers for React
This is a migrated thread and some comments may be shown as answers.
Mihai
Top achievements
Rank 1
Mihai asked on 27 Feb 2019, 12:10 AM

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>
                );
      }
}

6 Answers, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 28 Feb 2019, 08:25 AM
Hello Mihai,

The export package is built to work with other native react components including the kendo-react-grid.
https://www.telerik.com/kendo-react-ui/components/grid/excel-export/

In case you are using the react wrapper of the jQuery grid I would suggest you to use the jquery kendo export infrastructure.

Mixing the wrappers with the native components will not work for the excel and pdf exports.

Regards,
Vasil
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Mihai
Top achievements
Rank 1
answered on 28 Feb 2019, 05:59 PM

Hello Vasil,

Can you please check the example you have posted. I have downloaded it, installed the packages and when I run it locally it is returning an empty result set on excel export. Please see attached screen shot.

https://stackblitz.com/run/?file=app%2Fmain.js

Thanks & Regards,

Mihai

0
Mihai
Top achievements
Rank 1
answered on 28 Feb 2019, 06:07 PM

The link I posted is wrong. Is there no way to edit a post?

Here is the link to the app with the excel export not working:

https://zusf9f.run.stackblitz.io

Thanks & Regards,

Mihai

0
Mihai
Top achievements
Rank 1
answered on 28 Feb 2019, 06:07 PM

The I posted is wrong. Is there no way to edit a post?

Here is the link to the app with the excel feature not working:

https://zusf9f.run.stackblitz.io

Thanks & Regards,

Mihai

0
Mihai
Top achievements
Rank 1
answered on 28 Feb 2019, 07:06 PM

I have also implemented your example from your documentation at:

https://www.telerik.com/kendo-react-ui/components/grid/excel-export/

"Passing the Grid Columns"

and it is returning an empty result set on export, see picture attached. 

Can you please provide a working example of an excel export grid with the columns passed dynamically?

Thanks & Regards,

Mihai

0
Vasil
Telerik team
answered on 01 Mar 2019, 07:41 AM
Hi,

I can't open your code for some reason. But if I am guessing correct, you are placing the columns dynamically and changing them prior the export.
If that is the case, there is bug that will be fixed, and meanwhile there is different official way of passing the columns. Please follow these issue for further information:
https://github.com/telerik/kendo-react/issues/58

Regards,
Vasil
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Wrappers for React
Asked by
Mihai
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Mihai
Top achievements
Rank 1
Share this question
or