You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, `<Datagrid>` renders its header using `<DatagridHeader>`, an internal react-admin component. You can pass a custom component as the `header` prop to override that default. This can be useful e.g. to add a second header row, or to create headers spanning multiple columns.
2108
+
2109
+
For instance, here is a simple datagrid header that displays column names with no sort and no "select all" button:
<TableCell></TableCell> {/* empty cell to account for the select row checkbox in the body */}
2118
+
{Children.map(children, child=> (
2119
+
<TableCell key={child.props.source}>
2120
+
{child.props.source}
2121
+
</TableCell>
2122
+
))}
2123
+
</TableRow>
2124
+
</TableHead>
2125
+
);
2126
+
2127
+
constPostList=props=> (
2128
+
<List {...props}>
2129
+
<Datagrid header={<DatagridHeader />}>
2130
+
{/* ... */}
2131
+
</Datagrid>
2132
+
</List>
2133
+
);
2134
+
```
2135
+
2136
+
**Tip**: To handle sorting in your custom Datagrid header component, check out the [Building a custom sort control](#building-a-custom-sort-control) section.
2137
+
2104
2138
### Row Style Function
2105
2139
2106
2140
You can customize the `<Datagrid>` row style (applied to the `<tr>` element) based on the record, thanks to the `rowStyle` prop, which expects a function. React-admin calls this function for each row, passing the current record and index as arguments. The function should return a style object, which react-admin uses as a `<tr style>` prop.
0 commit comments