Skip to content

Commit 179dd1d

Browse files
authored
Merge pull request #6596 from mjomble/expandable-panel-class
Added expandedPanel to Datagrid styles
2 parents 315e82e + db3f8a7 commit 179dd1d

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

docs/List.md

+1
Original file line numberDiff line numberDiff line change
@@ -2394,6 +2394,7 @@ The `Datagrid` component accepts the usual `className` prop but you can override
23942394
| `expandIconCell` | Applied to each expandable cell |
23952395
| `expandIcon` | Applied to each expand icon |
23962396
| `expanded` | Applied to each expanded icon |
2397+
| `expandedPanel` | Applied to each expandable panel |
23972398
| `checkbox` | Applied to each checkbox cell |
23982399

23992400
You can customize the `<Datagrid>` styles by passing a `classes` object as prop, through `useStyles()`. Here is an example:

packages/ra-ui-materialui/src/list/datagrid/DatagridRow.tsx

+11-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,12 @@ const computeNbColumns = (expand, children, hasBulkActions) =>
4141
React.Children.toArray(children).filter(child => !!child).length // non-null children
4242
: 0; // we don't need to compute columns if there is no expand panel;
4343

44-
const defaultClasses = { expandIconCell: '', checkbox: '', rowCell: '' };
44+
const defaultClasses = {
45+
expandIconCell: '',
46+
checkbox: '',
47+
rowCell: '',
48+
expandedPanel: '',
49+
};
4550

4651
const DatagridRow: FC<DatagridRowProps> = React.forwardRef((props, ref) => {
4752
const {
@@ -204,7 +209,11 @@ const DatagridRow: FC<DatagridRowProps> = React.forwardRef((props, ref) => {
204209
)}
205210
</TableRow>
206211
{expandable && expanded && (
207-
<TableRow key={`${id}-expand`} id={`${id}-expand`}>
212+
<TableRow
213+
key={`${id}-expand`}
214+
id={`${id}-expand`}
215+
className={classes.expandedPanel}
216+
>
208217
<TableCell colSpan={nbColumns}>
209218
{isValidElement(expand)
210219
? cloneElement(expand, {

packages/ra-ui-materialui/src/list/datagrid/useDatagridStyles.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const useDatagridStyles = makeStyles(
4545
expanded: {
4646
transform: 'rotate(0deg)',
4747
},
48+
expandedPanel: {},
4849
}),
4950
{ name: 'RaDatagrid' }
5051
);

0 commit comments

Comments
 (0)