-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
[DataGrid] Add indexes relative to the filtered rows and the current page to the getRowClassName and getRowSpacing props
#3882
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
Merged
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
a3ba7be
[DataGrid] Pass the indexes relative to the row and the virtualizatio…
flaviendelangle 178b28f
Work
flaviendelangle e745fbf
Work
flaviendelangle 051becd
[DataGrid] Add support for margin between rows
m4theushw 802bd07
No 'margin'
m4theushw 8ad38da
Fix
flaviendelangle e6dd0df
Fix
flaviendelangle bfc8fdd
Adapt to dark mode
m4theushw 24088b0
Add unstable_getRowIndexRelativeToCurrentPage
m4theushw 1574c19
Update descriptions
m4theushw c1cdd8a
Merge branch 'master' into striped-rows
flaviendelangle 092be63
Work
flaviendelangle d2ac798
Fix
flaviendelangle effc3f8
Merge branch 'master' into margin-between-rows
m4theushw 138c722
Move getRowSpacing call to hydrateRowsMeta
m4theushw 80995ee
José's review
m4theushw c2c5cdc
Remove ignored method from docs
m4theushw f218e40
Merge branch 'master' into margin-between-rows
m4theushw cbd5383
Make it apply real margin
m4theushw eec647c
Add rowSpacingType
m4theushw 5aba750
Abstract params
m4theushw ee1307a
Rerun argos
m4theushw f4bca92
Merge branch 'master' into margin-between-rows
m4theushw 8c8f3a3
Remove 'as'
m4theushw 0429fee
Make getRowIndexRelativeToCurrentPage public
m4theushw 187de11
Use gridClasses
m4theushw 2ab6e6a
Merge
flaviendelangle 0e5b557
merge
flaviendelangle f0bd4d3
Merge
flaviendelangle 1e73cfd
Work
flaviendelangle 37981a3
Fix
flaviendelangle f70e677
Work
flaviendelangle 5fa769b
Merge
flaviendelangle affe84d
Merge branch 'master' into striped-rows
flaviendelangle 475d7da
Merge branch 'master' into striped-rows
flaviendelangle 3b25265
Merge
flaviendelangle 3f3c77c
Merge branch 'master' into striped-rows
flaviendelangle 8b95d8c
Work
flaviendelangle 9d4d980
Work
flaviendelangle 4632d69
Work
flaviendelangle d551b17
Update docs/data/data-grid/style/style.md
flaviendelangle d6b1323
Work
flaviendelangle edb129b
Merge branch 'master' into striped-rows
flaviendelangle ef7c982
Remove expanded index
flaviendelangle 0cac80d
Work
flaviendelangle 36069be
Merge
flaviendelangle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import * as React from 'react'; | ||
| import { alpha, styled } from '@mui/material/styles'; | ||
| import { DataGrid, gridClasses } from '@mui/x-data-grid'; | ||
| import { useDemoData } from '@mui/x-data-grid-generator'; | ||
|
|
||
| const ODD_OPACITY = 0.2; | ||
|
|
||
| const StripedDataGrid = styled(DataGrid)(({ theme }) => ({ | ||
| [`& .${gridClasses.row}.even`]: { | ||
| backgroundColor: theme.palette.grey[200], | ||
| '&:hover, &.Mui-hovered': { | ||
| backgroundColor: alpha(theme.palette.primary.main, ODD_OPACITY), | ||
| '@media (hover: none)': { | ||
| backgroundColor: 'transparent', | ||
| }, | ||
| }, | ||
| '&.Mui-selected': { | ||
| backgroundColor: alpha( | ||
| theme.palette.primary.main, | ||
| ODD_OPACITY + theme.palette.action.selectedOpacity, | ||
| ), | ||
| '&:hover, &.Mui-hovered': { | ||
| backgroundColor: alpha( | ||
| theme.palette.primary.main, | ||
| ODD_OPACITY + | ||
| theme.palette.action.selectedOpacity + | ||
| theme.palette.action.hoverOpacity, | ||
| ), | ||
| // Reset on touch devices, it doesn't add specificity | ||
| '@media (hover: none)': { | ||
| backgroundColor: alpha( | ||
| theme.palette.primary.main, | ||
| ODD_OPACITY + theme.palette.action.selectedOpacity, | ||
| ), | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| })); | ||
|
|
||
| export default function StripedGrid() { | ||
| const { data, loading } = useDemoData({ | ||
| dataSet: 'Employee', | ||
| rowLength: 200, | ||
| }); | ||
|
|
||
| return ( | ||
| <div style={{ height: 400, width: '100%' }}> | ||
| <StripedDataGrid | ||
| loading={loading} | ||
| {...data} | ||
| getRowClassName={(params) => | ||
| params.indexRelativeToCurrentPage % 2 === 0 ? 'even' : 'odd' | ||
| } | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import * as React from 'react'; | ||
| import { alpha, styled } from '@mui/material/styles'; | ||
| import { DataGrid, gridClasses } from '@mui/x-data-grid'; | ||
| import { useDemoData } from '@mui/x-data-grid-generator'; | ||
|
|
||
| const ODD_OPACITY = 0.2; | ||
|
|
||
| const StripedDataGrid = styled(DataGrid)(({ theme }) => ({ | ||
| [`& .${gridClasses.row}.even`]: { | ||
| backgroundColor: theme.palette.grey[200], | ||
| '&:hover, &.Mui-hovered': { | ||
| backgroundColor: alpha(theme.palette.primary.main, ODD_OPACITY), | ||
| '@media (hover: none)': { | ||
| backgroundColor: 'transparent', | ||
| }, | ||
| }, | ||
| '&.Mui-selected': { | ||
| backgroundColor: alpha( | ||
| theme.palette.primary.main, | ||
| ODD_OPACITY + theme.palette.action.selectedOpacity, | ||
| ), | ||
| '&:hover, &.Mui-hovered': { | ||
| backgroundColor: alpha( | ||
| theme.palette.primary.main, | ||
| ODD_OPACITY + | ||
| theme.palette.action.selectedOpacity + | ||
| theme.palette.action.hoverOpacity, | ||
| ), | ||
| // Reset on touch devices, it doesn't add specificity | ||
| '@media (hover: none)': { | ||
| backgroundColor: alpha( | ||
| theme.palette.primary.main, | ||
| ODD_OPACITY + theme.palette.action.selectedOpacity, | ||
| ), | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| })); | ||
|
|
||
| export default function StripedGrid() { | ||
| const { data, loading } = useDemoData({ | ||
| dataSet: 'Employee', | ||
| rowLength: 200, | ||
| }); | ||
|
|
||
| return ( | ||
| <div style={{ height: 400, width: '100%' }}> | ||
| <StripedDataGrid | ||
| loading={loading} | ||
| {...data} | ||
| getRowClassName={(params) => | ||
| params.indexRelativeToCurrentPage % 2 === 0 ? 'even' : 'odd' | ||
| } | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| <StripedDataGrid | ||
| loading={loading} | ||
| {...data} | ||
| getRowClassName={(params) => | ||
| params.indexRelativeToCurrentPage % 2 === 0 ? 'even' : 'odd' | ||
| } | ||
| /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.