Skip to content

Commit 6833126

Browse files
authored
Merge pull request #10884 from marmelab/docs/datagrid-codemod-limits
Document limits of Datagrid to DataTable codemod
2 parents 5a4b869 + 9d33028 commit 6833126

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

docs/DataTable.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,3 +1871,23 @@ npx jscodeshift ./path/to/src/ \
18711871
--parser=tsx \
18721872
--transform=./node_modules/ra-core/codemods/replace-Datagrid-DataTable.ts
18731873
```
1874+
1875+
Here is what the codemod will transform for you:
1876+
1877+
- Replace `<Datagrid>` with `<DataTable>`.
1878+
- Replace `rowStyle` with `rowSx`.
1879+
- Remove the `optimized` prop (which isn't necessary anymore)
1880+
- Rename the keys in `sx` prop from `"& .RaDatagrid-xxxx"` to `"& .RaDataTable-xxxx"`.
1881+
- Replace simple `<TextField>` with `<DataTable.Col>`.
1882+
- Replace simple `<NumberField>` with `<DataTable.NumberCol>`.
1883+
- Wrap all other fields in `<DataTable.Col>`, keeping `source` and `label` properties in `<DataTable.Col>`.
1884+
- Replace `Datagrid` imports by `DataTable`, and remove unused `TextField` and `NumberField` imports if they are now all replaced.
1885+
1886+
However, the codemod will **not**:
1887+
1888+
- Replace `<DatagridConfigurable>` with `<DataTable>` (column selection is now natively supported by `<DataTable>`).
1889+
- Remove the `sortBy` and `sortable` props on fields (sorting is now managed by `<DataTable.Col source>`)
1890+
- Move the `sortByOrder` prop from the field to `<DataTable.Col>`
1891+
- Replace a `<FunctionField>` child with `<DataTable.Col render>`
1892+
- Replace `<Datagrid>` from `@react-admin/ra-rbac` (and all its children). Refer to [Access Control section](#access-control) to use `<DataTable>` with `<CanAccess>`.
1893+
- Move the column styles from `<Datagrid sx>` to the individual `<DataTable.Col sx>`

0 commit comments

Comments
 (0)