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
For a given field, the filter configuration should be an object containing an array of `operators` and a default `input`, used for operators that don't define their own. You can use the [filter configuration builders](#filter-configuration-builders) (like `textFilter`) to build filter configuration objects.
107
115
108
-
An operator is an object that has a `label`, a `value` and a `type`.
116
+
An **operator** is an object that has a `label`, a `value`, a `defaultValue` and a `type`.
109
117
110
118
- The `label` is a string, and can be a translation key.
111
119
- The `value` is used as a suffix to the `source` and passed to the list filters.
120
+
- The `defaultValue` is used as the default filter value.
112
121
- The `type` ensures that when selecting an operator with a different type than the previous one, React-admin resets the filter value. Its value should be either `single` for filters that accepts a single value (for instance a `string`) or `multiple` for filters that accepts multiple values (for instance an `Array` of `string`). Should you need to differentiate a custom input from those two types, you may provide any type you want to the `type` option (for instance, `map`).
113
122
114
123
For instance, if the user adds the `views` filter with the `eq` operator and a value of `0`, the `dataProvider.getList()` will receive the following `filter` parameter:
@@ -117,6 +126,11 @@ For instance, if the user adds the `views` filter with the `eq` operator and a v
117
126
{ views_eq:0 }
118
127
```
119
128
129
+
In your filter declaration, you can provide an `operator`, an `input` and a `defaultValue`.
130
+
The **input** is a react object taking `source` as prop and rendering the input you will need to fill for your filter.
131
+
132
+
**Tip:** The **defaultValue** of a filter is not the same as the `defaultValue` of an `operator`.
133
+
120
134
## Filter Configuration Builders
121
135
122
136
To make it easier to create a filter configuration, `ra-form-layout` provides some helper functions. Each of them has predefined operators and inputs. They accept an array of operators if you want to remove some of them.
0 commit comments