Have been trying to use the pdfExport()
function from ej2-syncfusion GridComponent
, but cannot seem to make it work as a functional component.
Note: I am not using the class component. And the browser console reports Uncaught TypeError: grid.pdfExport is not a function
. I am probably missing something silly. What would be the functional component implementation of the code referred to in this documentation?
The way to do this is to reference the Grid and then call the pdfExport method within a callback which gets triggered on the toolbarClick.
const Component = () => {
let grid;
const toolbarClick = (args) => {
if (grid) {
if (args.item.id.includes('pdfexport')) {
grid.pdfExport();
}
}
}
return (
<GridComponent
ref={g => grid = g}
dataSource={data}
allowPdfExport
toolbar = {['PdfExport']}
toolbarClick={toolbarClick}
>
</GridComponent>
)
}