react-csv icon indicating copy to clipboard operation
react-csv copied to clipboard

Hiding a particular columns with react-csv

Open rkhemka06 opened this issue 6 years ago • 4 comments

Hi, I m using react-table to populate the data for my react-table. When I use react-csv to export data to csv it works but I have a functionality that allow user to hide or unhide table column on button click. ( I am saving boolean variable that hides a particular column by setting it to false) I want to export only those header where boolean is true and data associated with that header using react-csv.

rkhemka06 avatar Apr 11 '19 22:04 rkhemka06

I have a similar requirement like that , as a workaround I'm using a separate data source for export. Its really nice to have feature like this if we can add some show hide column settings.

mahbubulislam avatar Apr 24 '19 13:04 mahbubulislam

I'd like to get more peoples thoughts on this, but the aim of this library is to basically output what you give it. If you don't want something shown, then it should be omitted from the source data, not the responsibility of the library to do it.

We could add the functionality of a "hidden" variable in the headers prop, and I'd be happy to consider a PR. However, I'd like @mriccid and/or @abdennour thoughts on whether it would be an addition that would provide benefit

mccabemj avatar Jul 05 '19 13:07 mccabemj

I think you could just array.map your data and return objects that don't have the property/column that is now being hidden on your table.

leonimurilo avatar Sep 04 '19 18:09 leonimurilo

I think you could just array.map your data and return objects that don't have the property/column that is now being hidden on your table.

I implemented work around and works completely fine, its like adding extra methods to filter out the same data ,something which I think can be improved. But as @mccabemj suggested its upto @mriccid / @abdennour thoughts whether they think how this feature would provide benefit

rkhemka06 avatar Sep 30 '19 15:09 rkhemka06