Skip to content

Commit

Permalink
Merge pull request #4172 from marmelab/fix-cellClassName-shortcoming-…
Browse files Browse the repository at this point in the history
…documentation

Fix cellClassName shortcoming isn't documented
  • Loading branch information
djhi authored Dec 16, 2019
2 parents 3a1c591 + 735b224 commit 4e91885
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions docs/List.md
Original file line number Diff line number Diff line change
Expand Up @@ -1049,6 +1049,30 @@ const PostList = props => {
export default PostList;
```
Thi feature has a limit, though. `Datagrid` inspects its children for `headerClassName` and `cellClassName` props. This means you can't use these props in a *wrapped* component:
```jsx
const useStyles = makeStyles({
priceCell: { backgroundColor: 'blue' },
});

const PriceField = props => {
const classes = useStyles();
return <TextField cellClassName={classes.priceCell} {...props} />;
};

// the cell class name won't be applied here because Datagrid doesn't see it in its children
export const ProductList = (props) => (
<List {...props}>
<Datagrid>
<PriceField source="price" />
</Datagrid>
</List>
);
```
For this kind of use case, you need to use a [custom datagrid body component](#body-element).
### Performance
when displaying large pages of data, you might experience some performance issues.
Expand Down

0 comments on commit 4e91885

Please sign in to comment.