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

[DataGrid] Add header filters

Open nemonemi opened this issue 3 years ago • 21 comments

Duplicates

  • [X] I have searched the existing issues

Latest version

  • [X] I have tested the latest version

Summary 💡

I have a use case where I'm integrating a piece of an application suite and we have chosen the MUI's XGrid for our table solution. The rest of the suite uses AG grid, and since the whole suite should have the same look and feel I am tasked with adjusting the table's header to look and behave like AG grid's one does.

Examples 🌈

image

Motivation 🔦

What I need is a way to adjust the header so that the filter button is moved out of the header menu and to the place right below the header's cell name.

Also to have a thicker header that contains two rows

Order ID 💳 (optional)

No response

nemonemi avatar May 19 '22 13:05 nemonemi

Hi,

Thanks for your contribution You can have a look at #3719 which centralizes the various UI for filtering we are considering implementing.

You have issues linked there to implement is manually. But we have to do a clean implementation out of the box :+1:

flaviendelangle avatar May 19 '22 15:05 flaviendelangle

Hi @flaviendelangle, Thanks for the quick response. I went through the link(s) that you've provided, however, I haven't found anything that I could to make something like this: image

A double header where the second row has custom actionable elements, and that they have that line in between and column line separators.

Would you mind being a bit more specific, please?

nemonemi avatar May 20 '22 08:05 nemonemi

You can't create a second header row, you can only make your header row bigger to have two lines in it. We really need to implement it cleanly to support keyboard navigation out of the box.

flaviendelangle avatar May 20 '22 15:05 flaviendelangle

Any idea as to when we'll get API to make something like this?

nemonemi avatar Jul 06 '22 12:07 nemonemi

My team is implementing a part of a product that already uses AG grid, and we will have to make our tables' filters look and behave at least similar to the rest of the platform.

I would really appreciate progress in this direction.

I believe this ticket is similar to this one https://github.com/mui/mui-x/issues/3719

nemonemi avatar Aug 29 '22 12:08 nemonemi

I would be in favor of prioritizing this feature for Q4 because it clearly has a lot of traction

@joserodolfofreitas

flaviendelangle avatar Aug 30 '22 12:08 flaviendelangle

@flaviendelangle @oliviertassinari thanks for taking it on priority. we have strong use case for Mui data-grid with search/filter below headers (as our targeted users are not tech-savy to use current quick filter combinations). last week, we were evaluating possible solution & we put aside Mui data-grid only because of current ux complexity with quick filters. Looking forward to have this provision in mui-data-grid.

vishal-kadmos avatar Sep 02 '22 07:09 vishal-kadmos

I think #5973 also talks about the same topic

flaviendelangle avatar Sep 02 '22 07:09 flaviendelangle

Actually, this ticket is about having control of the header so that it can contain 2 (multiple) rows, like in the screenshot from the ticket.

The content of that second row is at the moment not that important, should it be an input field or a button triggering a dropdown would be another topic, I would say.

nemonemi avatar Sep 02 '22 08:09 nemonemi

I would suggest using something like the image below rather than a second-row header

image

israelKusayev avatar Sep 07 '22 14:09 israelKusayev

Please don't misunderstand this ticket. This issue is about having the second row, since that is what the rest of the platform that I am working on already has implemented, so for my use case, this is not a matter for discussion about which other option might be better.

nemonemi avatar Sep 07 '22 19:09 nemonemi

Basically we have 2 topics:

  1. Being able to add a filtering UI in the column header (most grids add a 2nd header row, @israelKusayev proposes an alternative UI, we need to decide how our built-in UI should look like)
  2. Being able to add a 2nd header row that user can fill with whatever they want (@nemonemi need)

flaviendelangle avatar Sep 08 '22 07:09 flaviendelangle

@flaviendelangle, Are you aware of any timeline existance for this?

nemonemi avatar Sep 09 '22 05:09 nemonemi

Not that I'm aware off :+1:

flaviendelangle avatar Sep 09 '22 06:09 flaviendelangle

@flaviendelangle As i am also awaiting for this feature to go with premium plan. Would be great if we can prioritise this. Thanks

vishal-kadmos avatar Sep 09 '22 07:09 vishal-kadmos

@oliviertassinari Would you mind shedding some light on to this topic?

nemonemi avatar Sep 09 '22 07:09 nemonemi

What would be needed to move this feature request forward?

nemonemi avatar Sep 14 '22 07:09 nemonemi

Time mostly

flaviendelangle avatar Sep 14 '22 08:09 flaviendelangle

+1 for this. We are also considering the premium version on this Component. Would be a game changer!

GabrielDierks avatar Sep 14 '22 10:09 GabrielDierks

Got it. We are currently unable to use the filtering feature due to the fact that it looks and behaves differently than the rest of the application. Any way to raise its priority?

nemonemi avatar Sep 14 '22 10:09 nemonemi

@israelKusayev your proposal relays on the placeholder of <input> to display the header name. If a column uses <select> or a custom component we don't have a placeholder to use. I would not consider it as an alternative to close #4934, although you can implement it passing a custom component to renderHeader.


The idea of rendering a second row is the best solution but we first need to rework the keyboard navigation to consider this new row and we already have #5879. Instead of this, I played with rendering a "second line" inside the same column headers already displayed. This approach is simpler to implement but needs a change on how the headerHeight prop works.

image

Despite the decision between second row or double-line column headers, there're other open questions.

  1. How to customize the operator used https://js.devexpress.com/Demos/WidgetsGallery/Demo/DataGrid/Filtering/jQuery/Light/ uses the magnifier icon to open a menu with the options available:

    image

    https://github.com/mui/mui-x/issues/3719 proposes a new attribute in the column definition, but it may not be explicit for the user how the filter works.

  2. Could this per-column filter also be changed via the filtering panel?

  3. Behavior if disableMultipleColumnsFiltering is enabled (e.g. in the community version)? My proposal would be to disable the inputs from the other columns once the input from a column is filled. The user will need to clear the input first to use another filter. We could also make #4934 a Pro-only feature.

m4theushw avatar Sep 19 '22 21:09 m4theushw

After 7 months it would be nice to see some progress here. @oliviertassinari, what would it take to raise the priority of this topic?

nemonemi avatar Dec 07 '22 09:12 nemonemi

@nemonemi From what I understand, this is a column header cell customization question. I would imagine that it can already be achieved. What blocker did you face?

For the quick filter features itself, we have #6247 and #5973 (same).

oliviertassinari avatar Dec 07 '22 18:12 oliviertassinari

Thank you for the quick response, @oliviertassinari. I basically need it to look and behave as the following photo indicates (from the top of the issue)

The desired goal In the solution that I've built the header needs to have a second row that fits nicely as in the photo (side dividers as in the column name). This row can contain anything but in my case a button that will trigger a showing of a filter that can be customized, e.g. like in the photos below:

Free search image

Dropdown & combinations image

Checkbox selection image

With date picker image

Now, all of these filter types are something that I wouldn't be expecting from the library, but I would appreciate the API or at least guidance on how to achieve this level of customization.

The reason why it has to look and behave like this is because of my team's decision to use the Mui-x instead of the Ag grid solution because of its flexibility, size, integration, etc., however, the rest of the platform uses the Ag grid, and we have to make it look and behave at least similar for the UI/UX cohesion's sake.

I have tried implementing it using the existing API and suggestions from those tickets, but the results were undesirable. For example, the second row, which I've added as a part of the column name, shared the side spacers.

Also, the flexibility of customizing the origin of the filter's dropdown, and their customization is also something that, as of yet, I believe is missing.

nemonemi avatar Dec 08 '22 13:12 nemonemi

Any progress with this topic? It would be useful to add this functionality.

alejandrosazo avatar Jan 19 '23 18:01 alejandrosazo

@nemonemi FYI, the filtering on header feature is released, which includes optimizability to add custom cells to the second header row. I would appreciate you trying it and providing any feedback if you have. Here's the link to the documentation where you can try it out: https://mui.com/x/react-data-grid/filtering/#header-filters

MBilalShafi avatar May 19 '23 15:05 MBilalShafi

A.mazing! Thanks for the notification. I'll definitely give it a go, asap :)

nemonemi avatar May 19 '23 15:05 nemonemi