Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Doc] Fix StackedFilters usage examples #9345

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions docs/FilteringTutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,15 @@ Another alternative filter UI is the Stacked Filters dialog, an [Enterprise Edit
Here is an example StackedFilters configuration:

```jsx
import {
List,
import {
BooleanField,
CreateButton,
Datagrid,
TextField,
List,
NumberField,
ReferenceArrayField,
BooleanField,
TextField,
TopToolbar,
} from 'react-admin';
import {
textFilter,
Expand All @@ -252,8 +254,15 @@ const postListFilters = {
tags: referenceFilter({ reference: 'tags' }),
};

const PostListToolbar = () => (
<TopToolbar>
<CreateButton />
<StackedFilters config={postListFilters} />
</TopToolbar>
);

const PostList = () => (
<List filters={<StackedFilters config={postListFilters} />}>
<List actions={<PostListToolbar />}>
<Datagrid>
<TextField source="title" />
<NumberField source="views" />
Expand Down
20 changes: 17 additions & 3 deletions docs/StackedFilters.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This [Enterprise Edition](https://marmelab.com/ra-enterprise)<img class="icon" s
Create a filter configuration object by specifying the operators and UI for each source that can be used as a filter. Then, pass it to the `<StackedFilters>` component, and pass that component to the `filters` prop of the `<List>` component.

```jsx
import { Datagrid, List, TextField, NumberField, BooleanField, ReferenceArrayField } from 'react-admin';
import { CreateButton, Datagrid, List, TextField, NumberField, BooleanField, ReferenceArrayField, TopToolbar } from 'react-admin';
import { StackedFilters, textFilter, dateFilter, referenceFilter, booleanFilter } from '@react-admin/ra-form-layout';

const postListFilters = {
Expand All @@ -28,8 +28,15 @@ const postListFilters = {
tags: referenceFilter({ reference: 'tags' }),
};

const PostListToolbar = () => (
<TopToolbar>
<CreateButton />
<StackedFilters config={postListFilters} />
</TopToolbar>
);

const PostList = () => (
<List filters={<StackedFilters config={postListFilters} />}>
<List actions={<PostListToolbar />}>
<Datagrid>
<TextField source="title" />
<NumberField source="views" />
Expand Down Expand Up @@ -120,8 +127,15 @@ const postListFilters = {
tags: referenceFilter({ reference: 'tags' }),
};

const PostListToolbar = () => (
<TopToolbar>
<CreateButton />
<StackedFilters config={postListFilters} />
</TopToolbar>
);

const PostList = () => (
<List filters={<StackedFilters config={postListFilters} />}>
<List actions={<PostListToolbar />}>
{/* ... */}
</List>
);
Expand Down