Is there a way to get data from server while exporting to CSV?
Hey,
I was going through http://allenfang.github.io/react-bootstrap-table/example.html#remote "Remote Exporting CSV" example and was wondering if there is a way to get data from the server in "onExportToCSV" method? The example shows a synchronous function which expects all the data to be present in the state before callling onExportToCSV. What if I don't want to load all the data ahead of time but want to get the data only when 'export to CSV' is clicked?
Any help is appreciated.
if there is a way to get data from the server in "onExportToCSV" method?
react-bootstrap-table does not support api for fetching data from server, but you can use your favor lib to do it in onExportToCSV function.
The example shows a synchronous function which expects all the data to be present in the state before callling onExportToCSV. What if I don't want to load all the data ahead of time but want to get the data only when 'export to CSV' is clicked?
that's a good question, I think it is not very well for async call, particular on this function, I'll find some solution, thanks
Yes, there is a way around the library by using callbacks
-
Create an exportCSVBtn
-
Change the handleExportCSVButtonClick method to fetch data using a callback and update the state of the table
-
Use the following method to export the rendered table
thisApp.refs.table.handleExportCSV() -
Don't foget to remove the onClick method being called
Let me know if you run in to any problems