diff --git a/docs/EditableDatagrid.md b/docs/EditableDatagrid.md index cf049a4308b..4fbcdd88980 100644 --- a/docs/EditableDatagrid.md +++ b/docs/EditableDatagrid.md @@ -36,20 +36,27 @@ yarn add @react-admin/ra-editable-datagrid Then, replace `` with `` in a react-admin ``, ``, or any other component that creates a `ListContext`. In addition, pass a form component to be displayed when the user switches to edit or create mode. ```tsx -import { List, ListActions,TextField, TextInput, DateField, DateInput, SelectField, SelectInput, required } from 'react-admin'; +import { + List, + ListActions, + TextField, + TextInput, + DateField, + DateInput, + SelectField, + SelectInput, + required, +} from 'react-admin'; import { EditableDatagrid, RowForm } from '@react-admin/ra-editable-datagrid'; export const ArtistList = () => ( } empty={false}> - } - editForm={} - > + } editForm={}> - + ); @@ -125,7 +132,6 @@ const RowAction = () => ( ``` @@ -169,6 +175,10 @@ Also, when the list is empty, the `` component normally doesn't render its **Tip**: The `createForm` component must render as many columns as there are children in the ``. That's why in the example above, the `` component renders a `` for each `` (except for the read-only `id` field, for which it renders a ``). +**Tip**: To display a create button on top of the list, you should add a `` component to the `actions` prop of the `` component, as in the example below. + +**Tip**: To display a custom create button, pass a custom component as the `empty` prop. It can use the `useEditableDatagridContext` hook to access to `openStandaloneCreateForm` and `closeStandaloneCreateForm` callbacks. + ## `editForm` The component displayed when a user clicks on a row to edit it. It's usually a form built with [``](#rowform), with the same number of children as the `` has children. @@ -212,7 +222,6 @@ Use the `mutationMode` prop to specify the [mutation mode](./Edit.md#mutationmod ``` @@ -232,6 +241,8 @@ You can disable the delete button by setting the `noDelete` prop to `true`: `` renders a form in a table row, with one table cell per child. It is designed to be used as [`editForm`](#editform) and [`createForm`](#createform) element. +`` and `` should have the same number of children, and these children should concern the same `source`. + ```tsx import { List, ListActions, TextField, TextInput } from 'react-admin'; import { EditableDatagrid, RowForm } from '@react-admin/ra-editable-datagrid'; @@ -258,8 +269,6 @@ const ArtistForm = () => ( ); ``` -`` and `` should have the same number of children, and these children should concern the same `source`. - **Tip**: No need to include a `` in the form, as `` automatically adds a column with save/cancel buttons. If you want to avoid the edition of a column, use a `` component instead of an `` component (like the `` in the example above). @@ -333,7 +342,6 @@ Feel free to visit the [dedicated stories](https://react-admin.github.io/ra-ente ## Using Inside a `` @@ -404,7 +412,6 @@ In these examples, the same form component is used in `createForm` and `editForm ## Providing Custom Side Effects @@ -574,7 +581,7 @@ const ArtistListWithMeta = () => { ``` {% endraw %} -## Configurable +## Configurable Variant You can let end users customize what fields are displayed in the `` by using the `` component instead, together with the `` component. @@ -585,7 +592,7 @@ You can let end users customize what fields are displayed in the ` ```diff -import { List, TextField } from 'react-admin'; +import { List, ListActions, TextField } from 'react-admin'; import { - EditableDatagrid, + EditableDatagridConfigurable,