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
Copy file name to clipboardexpand all lines: docs/FilterList.md
+45-111
Original file line number
Diff line number
Diff line change
@@ -5,130 +5,64 @@ title: "The FilterList Component"
5
5
6
6
# `<FilterList>`
7
7
8
+
An alternative UI to the Filter Button/Form Combo is the FilterList Sidebar. Similar to what users usually see on e-commerce websites, it's a panel with many simple filters that can be enabled and combined using the mouse.
9
+
8
10

9
11
10
-
An alternative UI to the Filter Button/Form Combo is the FilterList Sidebar. Similar to what users usually see on e-commerce websites, it's a panel with many simple filters that can be enabled and combined using the mouse. The user experience is better than the Button/Form Combo, because the filter values are explicit, and it doesn't require typing anything in a form. But it's a bit less powerful, as only filters with a finite set of values (or intervals) can be used in the `<FilterList>`.
12
+
The user experience is better than the Button/Form Combo, because the filter values are explicit, and it doesn't require typing anything in a form. But it's a bit less powerful, as only filters with a finite set of values (or intervals) can be used in the `<FilterList>`.
11
13
12
14
## Usage
13
15
14
-
The `<FilterList>` component expects a list of `<FilterListItem>` as children. Each `<FilterListItem>` defines a filter `label` and a `value`, which is merged with the current filter value when enabled by the user. Here is an example usage for a list of customers:
16
+
Use the `<FilterList>` component in a sidebar for the `<List>` view. It expects a list of `<FilterListItem>` as children. Each `<FilterListItem>` defines a filter `label` and a `value`, which is merged with the current filter value when enabled by the user.
17
+
18
+
For instance, here is a filter sidebar for a post list, allowing users to filter on two fields:
**Tip**: The `<Card sx>` prop in the `PostFilterSidebar` component above is here to put the sidebar on the left side of the screen, instead of the default right side.
61
+
62
+
A more sophisticated example is the filter sidebar for the visitors list visible in the screencast at the beginning of this page. The code for this example is available in the [react-admin repository](https://github.com/marmelab/react-admin/blob/master/examples/demo/src/visitors/VisitorListAside.tsx).
63
+
64
+
**Tip**: In a Filter List sidebar, you can use [the `<FilterLiveSearch>` component](./FilterLiveSearch.md) to add a search input at the top of the sidebar, and [the `<SavedQueriesList>` component](./SavedQueriesList.md) to add a list of saved queries.
65
+
132
66
`<FilterList>` accepts 3 props:
133
67
134
68
*[`children`](#children), which must be a list of `<FilterListItem>`
Copy file name to clipboardexpand all lines: docs/FilteringTutorial.md
+48
Original file line number
Diff line number
Diff line change
@@ -161,12 +161,60 @@ const postFilters = [
161
161
162
162
An alternative UI to the Filter Button/Form Combo is the FilterList Sidebar. Similar to what users usually see on e-commerce websites, it's a panel with many simple filters that can be enabled and combined using the mouse. The user experience is better than the Button/Form Combo, because the filter values are explicit, and it doesn't require typing anything in a form. But it's a bit less powerful, as only filters with a finite set of values (or intervals) can be used in the `<FilterList>`.
**Tip**: The `<Card sx>` prop in the `PostFilterSidebar` component above is here to put the sidebar on the left side of the screen, instead of the default right side.
207
+
164
208
Check [the `<FilterList>` documentation](./FilterList.md) for more information.
165
209
166
210
If you use the FilterList, you'll probably need a search input. As the FilterList sidebar is not a form, this requires a bit of extra work. Fortunately, react-admin provides a specialized search input component for that purpose: check [the `<FilterLiveSearch>` documentation](./FilterLiveSearch.md) for details.
167
211
168
212

169
213
214
+
Finally, a filter sidebar is the ideal place to display the user's favorite filters. Check [the `<SavedQueriesList>` documentation](./SavedQueriesList.md) for more information.
215
+
216
+

217
+
170
218
## Filter Operators
171
219
172
220
The internal format for storing filters and sending them to the dataProvider is an object, e.g.:
Copy file name to clipboardexpand all lines: docs/List.md
+45-1
Original file line number
Diff line number
Diff line change
@@ -137,7 +137,7 @@ const PostList = () => (
137
137
```
138
138
{% endraw %}
139
139
140
-
The `aside` component can call the `useListContext()` hook to receive the same props as the `List` child component. This means you can display additional details of the current list in the aside component:
140
+
The `aside` component can call the `useListContext()` hook to receive the same props as the `<List>` child component. This means you can display additional details of the current list in the aside component:
141
141
142
142
{% raw %}
143
143
```jsx
@@ -159,6 +159,50 @@ const Aside = () => {
159
159
```
160
160
{% endraw %}
161
161
162
+
The `aside` prop is also the preferred way to add a [Filter Sidebar](./FilteringTutorial.md#the-filterlist-sidebar) to a list view:
**Tip**: the `<Card sx>` prop in the `PostFilterSidebar` component above is here to put the sidebar on the left side of the screen, instead of the default right side.
205
+
162
206
## `children`: List Layout
163
207
164
208
`<List>` doesn't render any content by default - it delegates this to its child. List layout components grab the `data` from the `ListContext` and render them on screen.
Copy file name to clipboardexpand all lines: docs/SavedQueriesList.md
+2-5
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ title: "The SavedQueriesList Component"
7
7
8
8

9
9
10
-
`<SavedQueriesList>` renders a list of filters saved by the end user (and kept in [the Store](./Store.md)). It is a complement to `<FilterList>` sections for the filter sidebar
10
+
`<SavedQueriesList>` renders a list of filters saved by the end user (and kept in [the Store](./Store.md)). It is a complement to `<FilterList>` sections for [the filter sidebar](./FilteringTutorial.md#the-filterlist-sidebar).
11
11
12
12
## Usage
13
13
@@ -17,7 +17,7 @@ import {
17
17
FilterListItem,
18
18
List,
19
19
Datagrid
20
-
+SavedQueriesList
20
+
+ SavedQueriesList
21
21
} from 'react-admin';
22
22
import { Card, CardContent } from '@mui/material';
0 commit comments