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
|`children`| Required |`ReactNode`|| The component to render the list. |
77
+
|`filter`| Optional |`object`|| The filter to apply to the list. |
78
+
|`perPage`| Optional |`number`| 1000 | The number of items to display per page. |
79
+
|`sort`| Optional |`{ field, order}`|| The sort to apply to the list. |
80
+
|`storeKey`| Optional |`string`|| The key to use to store the records selection state|
80
81
81
82
`<ArrayField>` accepts the [common field props](./Fields.md#common-field-props), except `emptyText` (use the child `empty` prop instead).
82
83
@@ -217,6 +218,35 @@ By default, `<ArrayField>` displays the items in the order they are stored in th
217
218
```
218
219
{% endraw %}
219
220
221
+
## `storeKey`
222
+
223
+
By default, `ArrayField` stores the selection state in localStorage so users can revisit the page and find the selection preserved. The key for storing this state is based on the resource name, formatted as `${resource}.selectedIds`.
224
+
225
+
When displaying multiple lists with the same data source, you may need to distinguish their selection states. To achieve this, assign a unique `storeKey` to each `ArrayField`. This allows each list to maintain its own selection state independently.
226
+
227
+
In the example below, two `ArrayField` components display the same data source (`books`), but each stores its selection state under a different key (`books.selectedIds` and `custom.selectedIds`). This ensures that both components can coexist on the same page without interfering with each other's state.
228
+
229
+
```jsx
230
+
<Stack direction="row" spacing={2}>
231
+
<ArrayField
232
+
source="books"
233
+
storeKey="customOne"
234
+
>
235
+
<Datagrid>
236
+
<TextField source="title"/>
237
+
</Datagrid>
238
+
</ArrayField>
239
+
<ArrayField
240
+
source="books"
241
+
storeKey="customTwo"
242
+
>
243
+
<Datagrid>
244
+
<TextField source="title"/>
245
+
</Datagrid>
246
+
</ArrayField>
247
+
</Stack>
248
+
```
249
+
220
250
## Using The List Context
221
251
222
252
`<ArrayField>` creates a [`ListContext`](./useListContext.md) with the field value, so you can use any of the list context values in its children. This includes callbacks to sort, filter, and select items.
0 commit comments