Print Table

web
mobile

afshinshahpari@gmail.com pro premium asked 4 months ago

I am going to show different reports from json data and for that reason the best component that I thought that may be helpful is "Table". I wonder how I can print the content of "Table"? Do you have any tools for that? Thanks in advance


Aliaksandr Andrasiuk staff answered 4 months ago

Hi,

You can try to use exportToCSV property :

<MDBDataTable
  striped
  bordered
  hover
  exportToCSV
  data={data}
/>

It will render a button which allows you to download all the Table's data as .csv file. You can open this file by Microsoft Excel, for example, and then print it.

Hope I could help.


afshinshahpari@gmail.com pro premium commented 3 months ago

Thanks for your answer. Its not for my use to do this way, its for clients of my app and I need to have a print button on form to print it and this solution doesn't work, is there any other solution?


Aliaksandr Andrasiuk staff commented 3 months ago

Hi,

ExportToCSV uses the same named component, which you can import and add to your form component. This component excepts 2 properties: columns and data. You can pass a data.rows as data value.

So your imported ExportToCSV component will look like this:

import { MDBDataTable, ExportToCSV } from "mdbreact";

 <ExportToCSV columns={data.columns} data={data.rows} color="primary">
    Download
 </ExportToCSV>

You can try this approach. I hope this will meet your exceptions.

Best regards.


Please insert min. 20 characters.
Status

Answered

Specification of the issue
  • User: Pro
  • Premium support: Yes
  • Technology: React
  • MDB Version: 4.13.0
  • Device: mac
  • Browser: chrome
  • OS: macos
  • Provided sample code: No
  • Provided link: No
Tags
Related topics