diff --git a/packages/core/client/src/block-provider/TableBlockProvider.tsx b/packages/core/client/src/block-provider/TableBlockProvider.tsx
index 013c95dcf..03171f0c5 100644
--- a/packages/core/client/src/block-provider/TableBlockProvider.tsx
+++ b/packages/core/client/src/block-provider/TableBlockProvider.tsx
@@ -98,11 +98,7 @@ export const TableBlockProvider = (props) => {
-
+
diff --git a/packages/core/client/src/block-provider/TableSelectorProvider.tsx b/packages/core/client/src/block-provider/TableSelectorProvider.tsx
index 8c5849785..5e7efc7b5 100644
--- a/packages/core/client/src/block-provider/TableSelectorProvider.tsx
+++ b/packages/core/client/src/block-provider/TableSelectorProvider.tsx
@@ -79,7 +79,7 @@ const useAssociationNames2 = (collection) => {
return names;
};
-const recursiveParent = (schema: Schema, component) => {
+export const recursiveParent = (schema: Schema, component) => {
return schema['x-component'] === component
? schema
: schema.parent
@@ -149,7 +149,7 @@ export const TableSelectorProvider = (props: TableSelectorProviderProps) => {
if (props.dragSort) {
params['sort'] = ['sort'];
}
- if (collection?.tree && treeTable !== false) {
+ if (collectionField?.target === collectionField?.collectionName && collection?.tree && treeTable !== false) {
params['tree'] = true;
if (collectionFieldSchema.name === 'parent') {
params.filter = {
diff --git a/packages/core/client/src/schema-component/antd/table-v2/TableBlockDesigner.tsx b/packages/core/client/src/schema-component/antd/table-v2/TableBlockDesigner.tsx
index d06ac1759..ed9fb6278 100644
--- a/packages/core/client/src/schema-component/antd/table-v2/TableBlockDesigner.tsx
+++ b/packages/core/client/src/schema-component/antd/table-v2/TableBlockDesigner.tsx
@@ -43,9 +43,8 @@ export const TableBlockDesigner = () => {
const template = useSchemaTemplate();
const collection = useCollection();
const { dragSort, resource } = field.decoratorProps;
- const treeCollection = resource?.includes('.')
- ? getCollection(getCollectionField(resource)?.target)?.tree
- : !!collection?.tree;
+ const collectionField = getCollectionField(resource);
+ const treeCollection = resource?.includes('.') ? getCollection(collectionField?.target)?.tree : !!collection?.tree;
const dataScopeSchema = useMemo(() => {
return {
type: 'object',
@@ -84,11 +83,10 @@ export const TableBlockDesigner = () => {
},
[field],
);
-
return (
- {collection?.tree && (
+ {collection?.tree && collectionField?.collectionName === collectionField?.target && (
{
const { name, title } = useCollection();
+ const { getCollectionJoinField } = useCollectionManager();
const field = useField();
const fieldSchema = useFieldSchema();
const dataSource = useCollectionFilterOptions(name);
@@ -23,6 +25,8 @@ export const TableSelectorDesigner = () => {
const { dn } = useDesignable();
const defaultFilter = fieldSchema?.['x-decorator-props']?.params?.filter || {};
const defaultSort = fieldSchema?.['x-decorator-props']?.params?.sort || [];
+ const collectionFieldSchema = recursiveParent(fieldSchema, 'CollectionField');
+ const collectionField = getCollectionJoinField(collectionFieldSchema?.['x-collection-field']);
const sort = defaultSort?.map((item: string) => {
return item.startsWith('-')
? {
@@ -83,7 +87,7 @@ export const TableSelectorDesigner = () => {
});
}}
/>
- {collection?.tree && (
+ {collection?.tree && collectionField?.target === collectionField?.collectionName && (