Skip to content

Commit

Permalink
Merge pull request #6596 from mjomble/expandable-panel-class
Browse files Browse the repository at this point in the history
Added expandedPanel to Datagrid styles
  • Loading branch information
djhi authored Oct 15, 2021
2 parents 315e82e + db3f8a7 commit 179dd1d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/List.md
Original file line number Diff line number Diff line change
Expand Up @@ -2394,6 +2394,7 @@ The `Datagrid` component accepts the usual `className` prop but you can override
| `expandIconCell` | Applied to each expandable cell |
| `expandIcon` | Applied to each expand icon |
| `expanded` | Applied to each expanded icon |
| `expandedPanel` | Applied to each expandable panel |
| `checkbox` | Applied to each checkbox cell |

You can customize the `<Datagrid>` styles by passing a `classes` object as prop, through `useStyles()`. Here is an example:
Expand Down
13 changes: 11 additions & 2 deletions packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ const computeNbColumns = (expand, children, hasBulkActions) =>
React.Children.toArray(children).filter(child => !!child).length // non-null children
: 0; // we don't need to compute columns if there is no expand panel;

const defaultClasses = { expandIconCell: '', checkbox: '', rowCell: '' };
const defaultClasses = {
expandIconCell: '',
checkbox: '',
rowCell: '',
expandedPanel: '',
};

const DatagridRow: FC<DatagridRowProps> = React.forwardRef((props, ref) => {
const {
Expand Down Expand Up @@ -204,7 +209,11 @@ const DatagridRow: FC<DatagridRowProps> = React.forwardRef((props, ref) => {
)}
</TableRow>
{expandable && expanded && (
<TableRow key={`${id}-expand`} id={`${id}-expand`}>
<TableRow
key={`${id}-expand`}
id={`${id}-expand`}
className={classes.expandedPanel}
>
<TableCell colSpan={nbColumns}>
{isValidElement(expand)
? cloneElement(expand, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const useDatagridStyles = makeStyles(
expanded: {
transform: 'rotate(0deg)',
},
expandedPanel: {},
}),
{ name: 'RaDatagrid' }
);
Expand Down

0 comments on commit 179dd1d

Please sign in to comment.