gregnb / mui-datatables

Datatables for React using Material-UI
MIT License
2.7k stars 931 forks source link

Expand all rows Expandable Row Header? #740

Closed patorjk closed 4 years ago

patorjk commented 5 years ago

I was looking for this option but didn't see it - is there a way to have the header column for the expandable rows have an icon that will Expand/Close all of the rows?

gabrielliwerant commented 5 years ago

That option does not yet exist. Marking this as a duplicate as it has come up a number of times. You can follow the threads here for more information: https://github.com/gregnb/mui-datatables/issues/549, https://github.com/gregnb/mui-datatables/issues/518.

patorjk commented 5 years ago

It’s similar, though slightly different in that I’m looking to control via the column header. However, marking as a dup is fine, I’ll keep an eye on those other issues.

gabrielliwerant commented 5 years ago

You can already make custom column headers, so the only part that is missing is a way to programmaticly interact with the expand functionality. So if you had that, you would be able to do what you wanted.

patorjk commented 5 years ago

You can only create custom headers for columns in the Columns array. The expandable row options are set on the main options object and there isn’t a way to set its header (at least from what I can tell).

gabrielliwerant commented 5 years ago

It won't matter which object it's in, you could theoretically track any of it in your state and make any changes you wanted from the header, to the header, whatever, as long as you had the ability to trigger expandability at will.

patorjk commented 5 years ago

There’s no customHeadRender for the expandable row column though, you can’t change header for that column.

gabrielliwerant commented 5 years ago

Now I think that maybe I don't understand your issue. Not sure what you mean by "expandable row column." Expandable rows are rows, so not sure what columns have to do with it. If you want a column header that allows you toggle expandable rows, then that I understand. Maybe I need screenshots or something that demonstrate what you're trying to accomplish.

patorjk commented 5 years ago

Sorry if I’m not clear - I’m looking for something akin to the Select All/Unselect All checkbox header that the selectable rows have. So for the expandable rows column (by this I mean the column representing the arrow buttons that are pressed to open a row), I’m looking for an arrow I could push in the column header that would expand all of the rows or collapse all of the rows.

Part of this would be solved by what you’re talking about, but the other piece would be having the ability to have the column header there, since right now there’s no way to set that column header.

gabrielliwerant commented 5 years ago

Ok, I understand now. This is referred to as the select column since that's what it's used for now. You're right that there's no way currently to change the functionality in it. So you'd need a custom select header, but this is difficult because you'd need a way to maintain select functionality. I have to think about it, but I think it's going to be low priority to be able to customize the select column header this way. The more important ingredient to me is the ability to hook into the expand functionality. With that in place, there will be many options available for how to trigger it, including custom toolbars, custom columns, custom headers, etc. Just not the select header, at least not right away.

patorjk commented 5 years ago

Sounds good. I definitely would want to keep the select functionality., I didn't realize it was the same column (though I did notice it and the checkboxes stuck to the left part of the table when the table got too wide - which is useful), so that makes sense.

gabrielliwerant commented 5 years ago

@patorjk The expand functionality has been upgraded a few times, so I'm open to this contribution now, if you're still interested!

patorjk commented 5 years ago

It’s been in the back of my mind, I’ll take a look this coming week and report back.

gabrielliwerant commented 5 years ago

Sounds good @patorjk. That also gives me time to get in some improvements to expand rows which may or may not impact that work.