Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] Add an example for a fully customized filter panel outside the grid #4023

Open
joserodolfofreitas opened this issue Feb 23, 2022 · 3 comments
Labels
component: data grid This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation feature: Filtering Related to the data grid Filtering feature

Comments

@joserodolfofreitas
Copy link
Member

Motivation

Users are looking for a way to fully customize the filter panel and their inputs.

"We are looking to move the filter panel to a new location, that is static, and always showing, ideally above our DataGrid table.
Is it possible to customize the Filter panel in that way? I could not find any resources online for the above use case."

The panel only works inside the DataGrid currently, but we can support users to build their own filters with a good example.
The following codesandbox is a start:
https://codesandbox.io/s/controlledfilters-static-filter-field-0fvyev?file=/demo.js

Ideally, we should also provide an example/way of reusing our internal filter components to support these use cases without a lot of rewriting. But after a quick validation with @alexfauquette, right now, it's not possible to reuse the components outside the Grid (maybe after #3719).

@joserodolfofreitas joserodolfofreitas added component: data grid This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation feature: Filtering Related to the data grid Filtering feature labels Feb 23, 2022
@flaviendelangle
Copy link
Member

flaviendelangle commented Feb 23, 2022

right now, it's not possible to reuse the components outside the Grid

Those component uses hooks to access contexts containing apiRef and the props passed to the DataGrid.
They can be outside of the scope of the grid "by definition"

See #2522 for context. It's a major subject which is linked to all our discussions around plugins / headless api / etc...
We might be able to support it sooner with #2522 (comment).
But I think the filter demo should be in a custom Toolbar for the time being.

@oliviertassinari
Copy link
Member

oliviertassinari commented Feb 24, 2022

One step closer:

Screenshot 2022-02-24 at 00 20 40

https://codesandbox.io/s/datagriddemo-material-demo-forked-fyeb80?file=/demo.tsx

@flaviendelangle raised a great point, I got tricked when I used components.Headers initially for this demo. It prevents opening the column menu.
This makes me wonder, why do we even have components.Headers when we can use components.Toolbar? Should we deprecate components.Headers or rename it to something else a portal is not a header?


For #2522 maybe it could make sense to allow more flexibility, the same way it's done in the tabs: https://mui.com/components/tabs/#experimental-api

<TabContext value={value}>
  <Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
    <TabList onChange={handleChange} aria-label="lab API tabs example">
      <Tab label="Item One" value="1" />
      <Tab label="Item Two" value="2" />
      <Tab label="Item Three" value="3" />
    </TabList>
  </Box>
  <TabPanel value="1">Item One</TabPanel>
  <TabPanel value="2">Item Two</TabPanel>
  <TabPanel value="3">Item Three</TabPanel>
</TabContext>

@flaviendelangle
Copy link
Member

I don't have a strong reason why Headers exists in the 1st place
It adds an additional depth on the DOM and just instanciate the toolbar and a portal.

@m4theushw m4theushw moved this to 🆕 Needs triage in MUI X Data Grid Sep 9, 2022
@m4theushw m4theushw moved this from 🆕 Needs triage to 📋 Backlog in MUI X Data Grid Sep 9, 2022
@oliviertassinari oliviertassinari changed the title [docs] Add an example for a fully customized filter panel outside the grid. [docs] Add an example for a fully customized filter panel outside the grid Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: data grid This is the name of the generic UI component, not the React module! docs Improvements or additions to the documentation feature: Filtering Related to the data grid Filtering feature
Projects
Status: 📋 Backlog
Development

No branches or pull requests

4 participants