mui-datatables icon indicating copy to clipboard operation
mui-datatables copied to clipboard

Hide some columns in the table and show them in the view columns

Open mazenelorbany opened this issue 7 years ago • 6 comments

Expected Behavior

some columns are set to be unchecked from the view columns dropbox

Current Behavior

Code Snippet

`const emptabledisplay = props => { const { columns } = props.data;

const { data } = props.data;

const options = { filterType: "dropdown", responsive: "scroll" };

return ( <MUIDataTable title={"Employee list"} data={data} columns={columns} options={options} /> ); };

export default emptabledisplay; `

mazenelorbany avatar Jul 02 '19 03:07 mazenelorbany

Are you looking for these options?

image

gabrielliwerant avatar Jul 02 '19 04:07 gabrielliwerant

yes I think so but how can i use it properly into my code columns data looks like this image up to like 100

mazenelorbany avatar Jul 02 '19 04:07 mazenelorbany

Take a look at the customize-columns example. You will need to use a structure like that.

gabrielliwerant avatar Jul 02 '19 05:07 gabrielliwerant

I saw your response to a similar issue here #511 I managed to do it like this. `onst emptabledisplay = props => { const { columns } = props.data;

const { data } = props.data;

const options = { filterType: "dropdown", responsive: "stacked", rowsPerPage: 30 }; const headers = columns.map((value, key) => { if (key <= 12) { return { name: value, options: { display: true } }; } else return { name: value, options: { display: false } }; }); return ( <MUIDataTable title={"Employee list"} data={data} columns={headers} options={options} /> ); };

export default emptabledisplay;

like this the first 10 columns will be checked and the rest are unchecked image

mazenelorbany avatar Jul 02 '19 18:07 mazenelorbany

@gabrielliwerant is it possible to group the columns by a "theme" lets say Cars

  • Basic info
  • Technical specification
  • Gadgets

And then have a "show/hide all" button next to different headers? Lets say I only want to see the columns about gadgets? I have 50 columns in my table and they are "themed" and interesting for some users but not all. Would be nice to give them each a header and make de-select easy.

forssellm avatar Aug 13 '19 08:08 forssellm

@forssellm The functionality to group related columns does not exist at the moment, but you can create your own column headers with customHeadRender in the column options, and you can add buttons and functionality there if you wish. It should be possible for you to add what you're talking about with that, albeit it might be a bit of effort.

gabrielliwerant avatar Aug 16 '19 20:08 gabrielliwerant