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
|`sortBy`| Optional | `string | Function` |`source`| Name of the field to use for sorting when used in a Datagrid |
84
85
@@ -98,6 +99,7 @@ By default, `<ReferenceField>` renders the `recordRepresentation` of the referen
98
99
```
99
100
100
101
Alternatively, you can use [the `render` prop](#render) to render the referenced record in a custom way.
102
+
101
103
## `empty`
102
104
103
105
`<ReferenceField>` can display a custom message when the referenced record is missing, thanks to the `empty` prop.
@@ -172,6 +174,21 @@ You can also use a custom `link` function to get a custom path for the children.
172
174
/>
173
175
```
174
176
177
+
## `offline`
178
+
179
+
When the user is offline, `<ReferenceField>` is smart enough to display the referenced record if it was previously fetched. However, if the referenced record has never been fetched before, `<ReferenceField>` displays an error message explaining that the app has lost network connectivity.
180
+
181
+
You can customize this error message by passing a React element or a string to the `offline` prop:
182
+
183
+
```jsx
184
+
<ReferenceField source="user_id" reference="users" offline={<span>No network, could not fetch data</span>} >
185
+
...
186
+
</ReferenceField>
187
+
<ReferenceField source="user_id" reference="users" offline="No network, could not fetch data">
188
+
...
189
+
</ReferenceField>
190
+
```
191
+
175
192
## `queryOptions`
176
193
177
194
Use the `queryOptions` prop to pass options to [the `dataProvider.getMany()` query](./useGetOne.md#aggregating-getone-calls) that fetches the referenced record.
The `render` function prop will take priority on `children` props if both are set.
131
-
132
104
## `empty`
133
105
134
106
`<ReferenceFieldBase>` can display a custom message when the referenced record is missing, thanks to the `empty` prop.
@@ -155,6 +127,21 @@ You can pass either a React element or a string to the `empty` prop:
155
127
</ReferenceFieldBase>
156
128
```
157
129
130
+
## `offline`
131
+
132
+
When the user is offline, `<ReferenceFieldBase>` is smart enough to display the referenced record if it was previously fetched. However, if the referenced record has never been fetched before, `<ReferenceFieldBase>` displays an error message explaining that the app has lost network connectivity.
133
+
134
+
You can customize this error message by passing a React element or a string to the `offline` prop:
135
+
136
+
```jsx
137
+
<ReferenceFieldBase source="user_id" reference="users" offline={<span>No network, could not fetch data</span>} >
138
+
...
139
+
</ReferenceFieldBase>
140
+
<ReferenceFieldBase source="user_id" reference="users" offline="No network, could not fetch data">
141
+
...
142
+
</ReferenceFieldBase>
143
+
```
144
+
158
145
## `queryOptions`
159
146
160
147
Use the `queryOptions` prop to pass options to [the `dataProvider.getMany()` query](./useGetOne.md#aggregating-getone-calls) that fetches the referenced record.
@@ -186,6 +173,36 @@ For instance, if the `posts` resource has a `user_id` field, set the `reference`
186
173
</ReferenceFieldBase>
187
174
```
188
175
176
+
177
+
## `render`
178
+
179
+
Alternatively, you can pass a `render` function prop instead of children. This function will receive the `ReferenceFieldContext` as argument.
The `render` function prop will take priority on `children` props if both are set.
205
+
189
206
## `sortBy`
190
207
191
208
By default, when used in a `<Datagrid>`, and when the user clicks on the column header of a `<ReferenceFieldBase>`, react-admin sorts the list by the field `source`. To specify another field name to sort by, set the `sortBy` prop.
0 commit comments