-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[docs][data grid] Revise the Data Grid getting started docs #15757
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 42 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
53481a9
init
mapache-salvaje 839fb57
Merge branch 'master' into datagrid-gsd
mapache-salvaje 32a6f8c
prettier
mapache-salvaje f2124ad
getting-started first pass
mapache-salvaje b99199c
nbsps
mapache-salvaje 87ac014
revert out of scope change
mapache-salvaje aa63e17
broken links
mapache-salvaje 2fe2f2a
Merge branch 'master' into datagrid-gsd
mapache-salvaje 2d6e07a
one package to import
mapache-salvaje 507d94d
overview
mapache-salvaje 8c22a91
not also
mapache-salvaje d4554d8
copyedit popular features demo
mapache-salvaje aed9181
Merge branch 'master' into datagrid-gsd
mapache-salvaje 7e28bcc
18adff3
merge master
mapache-salvaje 19fd0b1
feature showcase copy
mapache-salvaje cec1654
restore api sections
mapache-salvaje a82ded8
gs to quickstart, success callout
mapache-salvaje 0298584
move content from faq to perf, first pass at perf content
mapache-salvaje 1725e46
performance page
mapache-salvaje bef6003
move content from faq
mapache-salvaje 62a8e5b
introduce cells page
mapache-salvaje 84bd7ea
remove faqs
mapache-salvaje 1c2c060
cells page first pass
mapache-salvaje e8c1bb2
Merge branch 'master' into datagrid-gsd
mapache-salvaje 620c689
1ce51e0
updates
mapache-salvaje 2acfff1
revert out of scope changes
mapache-salvaje b916112
weird change
mapache-salvaje be63db1
Merge branch 'master' into datagrid-gsd
mapache-salvaje 5d6cf31
rendercell
mapache-salvaje 14e395a
cells page
mapache-salvaje 11d3950
perf final? pass
mapache-salvaje 93cf83b
remove line breaks
mapache-salvaje 13a4c61
quickstart callout
mapache-salvaje 498a950
overview and quickstart final pass
mapache-salvaje e0b8f6c
cells final pass
mapache-salvaje 41a8ba0
revert out of scope charts changes
mapache-salvaje c7748be
Update docs/data/data-grid/cells/cells.md
mapache-salvaje 889fd98
drop function in headers
mapache-salvaje 31954e0
funtion formatting
mapache-salvaje 74dd7fa
Merge branch 'master' into datagrid-gsd
mapache-salvaje a327d2e
perf page ale feedback
mapache-salvaje 57b5158
Merge branch 'master' into datagrid-gsd
mapache-salvaje 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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
Broken links found by `docs:link-check` that exist: | ||
|
||
- https://mui.com/x/react-data-grid/#premium-plan | ||
- https://mui.com/x/react-data-grid/getting-started/#feature-comparison | ||
- https://mui.com/x/react-date-pickers/fields/#accessible-dom-structure |
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,70 @@ | ||
# Data Grid - Cells | ||
|
||
<p class="description">Learn how to customize the rendered elements and values of a cell.</p> | ||
|
||
## Customizing cells | ||
|
||
The Data Grid provides several methods for customizing the rendered elements and values of a cell, including `renderCell()`, `valueGetter()`, and `valueFormatter()`. | ||
This document describes the key differences and specific use cases for each. | ||
|
||
### renderCell() | ||
|
||
Use the `renderCell()` function to render any element inside of a cell. | ||
This is the only way to render a React component inside a cell, and also the only way to customize a cell's behavior—for example, by adding a click handler. | ||
|
||
Though powerful, it's also expensive in terms of performance, so it should only be used as a last resort when there are no other means for implementing a specific use case. | ||
|
||
Here's an example of a cell that uses `renderCell()` to render a button: | ||
|
||
```tsx | ||
const columns: GridColDef[] = [ | ||
{ | ||
field: 'date', | ||
headerName: 'Year', | ||
renderCell: (params: GridRenderCellParams<any, Date>) => ( | ||
<strong> | ||
{params.value.getFullYear()} | ||
<Button | ||
variant="contained" | ||
size="small" | ||
style={{ marginLeft: 16 }} | ||
tabIndex={params.hasFocus ? 0 : -1} | ||
> | ||
Open | ||
</Button> | ||
</strong> | ||
), | ||
}, | ||
]; | ||
``` | ||
|
||
See [Column definition—Rendering cells](/x/react-data-grid/column-definition/#rendering-cells) for more details. | ||
|
||
### valueGetter() | ||
|
||
Use the `valueGetter()` function to derive a cell's value from the row data. | ||
This is the the most performant way to customize the contents of a cell, and it does so without altering the row data itself. | ||
|
||
Common use cases include: | ||
|
||
- Transforming a value (for example, converting a decimal value to a percentage value) | ||
- Deriving a value from multiple fields (for example, concatenating first name and last name) | ||
- Deriving a value from a nested field (for example, `user.address.city`) | ||
|
||
This function is also used internally in the Data Grid to filter, sort, and render (if `renderCell()` or `valueFormatter()` are not provided). | ||
|
||
See [Column definition—Value getter](/x/react-data-grid/column-definition/#value-getter) for more details. | ||
|
||
### valueFormatter() | ||
|
||
Use the `valueFormatter()` function to format a cell's value (without changing the underlying row data). | ||
|
||
Common use cases include: | ||
|
||
- Formatting a date to a custom display format | ||
- Formatting a decimal value to a percentage and appending a `%` sign | ||
- Formatting a boolean value to `Yes` or `No` | ||
|
||
Unlike `valueGetter()`, this function only impacts rendering—_not_ internal calculations like filtering or sorting. | ||
|
||
See [Column definition—value formatter](/x/react-data-grid/column-definition/#value-formatter) for more details. |
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To revert, this is wrong, those links are broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe these are links from the
@mui/material
repo in the blog. I'll open a PR there to address them.