0

I have integrated material table in react (reference: https://material-table.com/).

I want to export the displayed data (all data and search results) to PDF using jspdf. Unable to get that in material table.

Unfortunately, I'm unable to get all the data as well as searched data.

Can anyone help?

Guillermo Cacheda
  • 2,162
  • 14
  • 23
  • Can you provide some code on how you pass the data etc? – Domino987 Aug 30 '19 at 07:19
  • { alert('You should develop a code to export ' + data.length + ' rows'); } }} actions={[ { icon: 'Export', tooltip: 'Export to pdf', isFreeAction: true, onClick: (event ,tdata) =>console.log("event data==>> ",this.props.data) } ]} /> – supriya chavan Sep 03 '19 at 08:54
  • All the data is available in export to csv option. Similar way I am looking into getting the data when export to pdf.. Thanks – supriya chavan Sep 03 '19 at 08:55
  • So you you can access the data in the csv option. What exactly is the problem than? – Domino987 Sep 03 '19 at 10:09
  • export to csv is for excel.. I want to do that for PDF.. exporting material table data to pdf.. in export csv data is available.. outside that function data all data and/or searched data is not available for exporting it to any other format – supriya chavan Sep 04 '19 at 05:12
  • export const materialTableOptions: Options = { exportButton: { csv: true, pdf: true } }; – szachMati Nov 27 '20 at 09:27

1 Answers1

0

Try to useRef() from react.

import {useRef} from "react";

const YourComponent = () => {
    const tableRef = useRef();

    console.log(tableRef.current.dataManager.data); // check proper field

    return <MaterialTable tableRef={tableRef} {...restProps} />;
}