DarkGuardsman
DarkGuardsman

Reputation: 136

react-bootstrap-table2 csv prevent export hidden columns

Using react-bootstrap-table2 how would I go about preventing exporting hidden columns in the csv export component? Currently my UI has the ability to hide columns using the built in column toggle feature in react-bootstrap-table2. However, by default csv will export all columns.

There seems to be a way to do this by row but not seeing anything for by column https://react-bootstrap-table.github.io/react-bootstrap-table2/storybook/index.html?selectedKind=Export%20CSV&selectedStory=Only%20Export%20Filtered%2FSearched%20Rows&full=0&addons=1&stories=1&panelRight=0&addonPanel=storybook%2Factions%2Factions-panel

Upvotes: 0

Views: 1960

Answers (1)

Antoine Gagnon
Antoine Gagnon

Reputation: 982

According to this part about hiding columns, you can simply add csvExport: false to the column you do not want to export and it will not be exported.

To do it dynamically, you could add a method that is called when a column is toggled (defined in the ToggleList documentation which will manually set csvExport to true or false on the column that was toggled.

Upvotes: 1

Related Questions