material-table icon indicating copy to clipboard operation
material-table copied to clipboard

Set default columns for columnsButton

Open calebhypes opened this issue 7 years ago • 6 comments

Is your feature request related to a problem? Please describe. I have a table with over 40 different columns, this causes the table to be quite lengthy so I use columnsButton: true to allow users to select columns.

Describe the solution you'd like By default, all columns listed render automatically and are selected within the Show/Hide columns window, It would be nice to have a key/value for the columns prop similar to the below:

columns={ title: 'Name', field: 'name', defaultColumn: true }

Describe alternatives you've considered Only current alternative that I've seen is to add columns as a state item and update the component on state change. I've not tried this as of yet.

calebhypes avatar Mar 25 '19 19:03 calebhypes

You can add hidden: true to your column definition. It will hide these columns by default.

mbrn avatar Mar 25 '19 19:03 mbrn

@mbrn that's exactly what I was looking for, apologies for the confusion on my end, I didn't see the hidden value in docs at first! Thank you for pointing me in the right direction.

calebhypes avatar Mar 25 '19 20:03 calebhypes

No problem @CalebCox , feel free to ask. I can help as possible as

mbrn avatar Mar 25 '19 20:03 mbrn

Hi, this doesn't work anymore as hidden=true, remove the column from the columnsButton list. What is the other alternative? Thanks

LaetitiaDall avatar Sep 18 '20 07:09 LaetitiaDall

same hidden=true, remove the column from the columnsButton list event with hiddenByColumnsButton: false

guillaume-rachet avatar Mar 24 '21 17:03 guillaume-rachet

@LaetitiaDall @grachet Found any alternatives?

VidushaZ avatar Jul 31 '21 15:07 VidushaZ