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: adminforth/documentation/docs/tutorial/07-Plugins/03-ForeignInlineList.md
+89-2Lines changed: 89 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -72,9 +72,96 @@ Add to your `'adminuser'` resource configuration the plugin instance:
72
72
}
73
73
```
74
74
75
-
You can use `modifyTableResourceConfig` callback to modify what columns to show in the list and filter of the foreign table.
75
+
You can use the `modifyTableResourceConfig` callback to modify which columns to show in the list and filter of the foreign table.
76
76
77
77

78
78
79
79
> 👆 To make plugin work, the specified resource (defined with `foreignResourceId`) should have one (and only one) column that refers to the current resource on which you add a plugin.
80
-
> In our case we add plugin to `adminuser` resource, so the `aparts` resource should have one column with `foreignResource.resourceId` equal to `adminuser` resourceId.
80
+
> In our case we add plugin to `adminuser` resource, so the `aparts` resource should have one column with `foreignResource.resourceId` equal to `adminuser` resourceId.
81
+
82
+
## Default filters
83
+
84
+
If you need to add default filters for the foreign resource based on your current record (for example show apartment only from Italy, when user have country Italy), you can use defaultFilters callback:
85
+
>👆 This example won't work until you'll add counrty field in your adminuser resource and it's only for demonstrating concept of callback
86
+
87
+
```ts title="./resources/adminuser.ts"
88
+
89
+
...
90
+
91
+
newForeignInlineListPlugin({
92
+
93
+
...
94
+
//diff-add
95
+
defaultFilters: (record:any) => {
96
+
//diff-add
97
+
return [
98
+
//diff-add
99
+
{
100
+
//diff-add
101
+
field: "country",
102
+
//diff-add
103
+
operator: AdminForthFilterOperators.EQ,
104
+
//diff-add
105
+
value: record.country,
106
+
//diff-add
107
+
}
108
+
//diff-add
109
+
]
110
+
//diff-add
111
+
}
112
+
113
+
...
114
+
115
+
})
116
+
117
+
...
118
+
119
+
```
120
+
121
+
>👆It also makes sense to modify the table resource and hide the country field from filters, because this value is hardcoded and equals the country from the record:
0 commit comments