Skip to content

Commit e04cb1e

Browse files
authored
Merge pull request #9086 from marmelab/doc-improve-documentation-about-disabling-features-bulk-actions-etc
[Doc] add sections to explain explicitly how to disable features like bulk actions
2 parents 89d06d3 + 70dd9bf commit e04cb1e

File tree

7 files changed

+139
-1
lines changed

7 files changed

+139
-1
lines changed

docs/Datagrid.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,3 +1201,36 @@ const MyCustomList = () => {
12011201
);
12021202
};
12031203
```
1204+
1205+
## How to disable checkboxes
1206+
1207+
You can disable bulk actions altogether by passing `false` to the `bulkActionButtons` prop. In this case, the checkboxes column doesn’t show up anymore.
1208+
1209+
```tsx
1210+
import { Datagrid, List } from 'react-admin';
1211+
1212+
export const PostList = () => (
1213+
<List>
1214+
<Datagrid bulkActionButtons={false}>
1215+
...
1216+
</Datagrid>
1217+
</List>
1218+
);
1219+
```
1220+
1221+
## Disable column sorting
1222+
1223+
In a `<Datagrid>`, users can change the sort field and order by clicking on the column headers. You may want to disable this behavior for a given field (e.g. for reference or computed fields). In that case, pass a `false` value to the `sortable` prop on the field.
1224+
1225+
```jsx
1226+
const PostList = () => (
1227+
<List>
1228+
<Datagrid>
1229+
<TextField source="title" />
1230+
<ReferenceField source="author_id" sortable={false}>
1231+
<TextField source="name" />
1232+
</ReferenceField>
1233+
</Datagrid>
1234+
</List>
1235+
);
1236+
```

docs/Fields.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,17 @@ const BookEdit = () => (
368368
);
369369
```
370370

371+
## Hiding A Field Label
372+
373+
You can opt out of the label decoration by passing `false` to the `label` prop.
374+
375+
```jsx
376+
// No label will be added
377+
<TextField source="author.name" label={false} />
378+
```
379+
380+
**Note**: This prop has no effect when rendering a field outside a `<Datagrid>`, a `<SimpleShowLayout>`, a `<TabbedShowLayout>`, a `<SimpleForm>`, or a `<TabbedForm>`.
381+
371382
## Conditional Formatting
372383

373384
If you want to format a field depending on the value, create another component wrapping this field, and set the `sx` prop depending on the field value:

docs/Inputs.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,3 +910,13 @@ You can find components for react-admin in third-party repositories.
910910
- [@react-page/react-admin](https://react-page.github.io/docs/#/integration-react-admin): ReactPage is a rich content editor and comes with a ready-to-use React-admin input component. [check out the demo](https://react-page.github.io/examples/reactadmin)
911911

912912
- **DEPRECATED V3** [LoicMahieu/aor-tinymce-input](https://github.com/LoicMahieu/aor-tinymce-input): a TinyMCE component, useful for editing HTML
913+
914+
## Hiding the label
915+
916+
You can set `label={false}` on an input component to hide its label.
917+
918+
```jsx
919+
<TextInput source="title" /> {/* input label is "Title" */}
920+
<TextInput source="title" label="Post title" /> {/* input label is "Post title" */}
921+
<TextInput source="title" label={false} /> {/* input has no label */}
922+
```

docs/List.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,4 +1006,46 @@ const PostList = () => (
10061006
);
10071007
```
10081008

1009-
The list will automatically update when a new record is created, or an existing record is updated or deleted.
1009+
The list will automatically update when a new record is created, or an existing record is updated or deleted.
1010+
1011+
## How to render an empty list
1012+
1013+
You can set the `empty` props value to `false` to bypass the empty page display and render an empty list instead.
1014+
1015+
```tsx
1016+
import { List } from 'react-admin';
1017+
1018+
const ProductList = () => (
1019+
<List empty={false}>
1020+
...
1021+
</List>
1022+
)
1023+
```
1024+
1025+
## How to remove the `<ExportButton>`
1026+
1027+
You can remove the `<ExportButton>` by passing `false` to the `exporter` prop.
1028+
1029+
```tsx
1030+
import { List } from 'react-admin';
1031+
1032+
const ProductList = () => (
1033+
<List exporter={false}>
1034+
...
1035+
</List>
1036+
)
1037+
```
1038+
1039+
## How to disable storing the list parameters in the Store
1040+
1041+
You can disable the `storeKey` feature by setting the `storeKey` prop to `false`. When disabled, the list parameters will not be persisted in [the Store](./Store.md).
1042+
1043+
```tsx
1044+
import { List } from 'react-admin';
1045+
1046+
const ProductList = () => (
1047+
<List storeKey={false}>
1048+
...
1049+
</List>
1050+
)
1051+
```

docs/ReferenceField.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,3 +301,12 @@ React-admin accumulates and deduplicates the ids of the referenced records to ma
301301
```
302302

303303
Then react-admin renders the `<PostList>` with a loader for the `<ReferenceField>`, fetches the API for the related users in one call (`dataProvider.getMany('users', { ids: [789,735] }`), and re-renders the list once the data arrives. This accelerates the rendering and minimizes network load.
304+
305+
## Removing the link
306+
307+
You can prevent `<ReferenceField>` from adding a link to its children by setting `link` to `false`.
308+
309+
```jsx
310+
// No link
311+
<ReferenceField source="user_id" reference="users" link={false} />
312+
```

docs/ReferenceOneField.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,3 +223,13 @@ const BookShow = () => (
223223
);
224224
```
225225
{% endraw %}
226+
227+
## Removing the link
228+
229+
By default, `<ReferenceOneField>` links to the edition page of the related record. You can disable this behavior by setting the `link` prop to `false`.
230+
231+
```jsx
232+
<ReferenceOneField label="Genre" reference="book_details" target="book_id" link={false}>
233+
<TextField source="genre" />
234+
</ReferenceOneField>
235+
```

docs/SimpleShowLayout.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,29 @@ The `<SimpleShowLayout>` component accepts the usual `className` prop but you ca
206206

207207
To override the style of all instances of `<SimpleShowLayout>` using the [Material UI style overrides](https://mui.com/material-ui/customization/theme-components/#theme-style-overrides), use the `RaSimpleShowLayout` key.
208208

209+
## Hiding the labels
210+
211+
You can disable the `<Labeled>` decoration added by `<SimpleShowLayout>` by passing setting `label={false}` on a field:
212+
213+
```jsx
214+
const PostShow = () => (
215+
<Show>
216+
<SimpleShowLayout>
217+
<TextField label={false} source="title" />
218+
</SimpleShowLayout>
219+
</Show>
220+
);
221+
222+
// translates to
223+
const PostShow = () => (
224+
<Show>
225+
<Stack>
226+
<TextField source="title" />
227+
</Stack>
228+
</Show>
229+
);
230+
```
231+
209232
## See Also
210233

211234
* [Field components](./Fields.md)

0 commit comments

Comments
 (0)