Skip to content

Commit

Permalink
[data grid] Adds a recipe for using non-native select in filter panel (
Browse files Browse the repository at this point in the history
  • Loading branch information
michelengelen authored Nov 7, 2023
1 parent 289ed7a commit fe5198c
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
26 changes: 26 additions & 0 deletions docs/data/data-grid/filtering-recipes/UseNonNativeSelect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from 'react';
import { DataGrid } from '@mui/x-data-grid';
import { useDemoData } from '@mui/x-data-grid-generator';

const VISIBLE_FIELDS = ['name', 'rating', 'country', 'dateCreated', 'isAdmin'];

export default function UseNonNativeSelect() {
const { data } = useDemoData({
dataSet: 'Employee',
visibleFields: VISIBLE_FIELDS,
rowLength: 100,
});

return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid
{...data}
slotProps={{
baseSelect: {
native: false,
},
}}
/>
</div>
);
}
26 changes: 26 additions & 0 deletions docs/data/data-grid/filtering-recipes/UseNonNativeSelect.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from 'react';
import { DataGrid } from '@mui/x-data-grid';
import { useDemoData } from '@mui/x-data-grid-generator';

const VISIBLE_FIELDS = ['name', 'rating', 'country', 'dateCreated', 'isAdmin'];

export default function UseNonNativeSelect() {
const { data } = useDemoData({
dataSet: 'Employee',
visibleFields: VISIBLE_FIELDS,
rowLength: 100,
});

return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid
{...data}
slotProps={{
baseSelect: {
native: false,
},
}}
/>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<DataGrid
{...data}
slotProps={{
baseSelect: {
native: false,
},
}}
/>
6 changes: 6 additions & 0 deletions docs/data/data-grid/filtering-recipes/filtering-recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ Currently if you want to use the [Quick filter](/x/react-data-grid/filtering/qui
A common use case is to have certain components positioned outside of the grid. Because of the way the grid context works this might not be a straining forward thing to do. The example below illustrates how this use case can be achieved.

{{"demo": "QuickFilterOutsideOfGrid.js", "bg": "inline", "defaultCodeOpen": false}}

## Use non-native select in filter panel

If you do not want to use the native select in the filtering panel you can switch it to the `@mui/material/Select` component by using the `slotProps` property.

{{"demo": "UseNonNativeSelect.js", "bg": "inline", "defaultCodeOpen": false}}

0 comments on commit fe5198c

Please sign in to comment.