Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!

afshinshahpari@gmail.com free asked 5 years 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 5 years 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 free commented 5 years 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 5 years 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.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: 4.13.0
  • Device: mac
  • Browser: chrome
  • OS: macos
  • Provided sample code: No
  • Provided link: No