fix(components): [table] the toggleTreeExpansion failed to trigger load function (#18728)

* feat(components): [table] fix lazy loading

* Modify the function usage
This commit is contained in:
pengpeng
2025-01-26 15:21:56 +08:00
committed by GitHub
parent b009be7c17
commit d2e269f772

View File

@@ -161,7 +161,9 @@ function useTree<T>(watcherData: WatcherPropsData<T>) {
expandRowKeys.value = value
updateTreeData()
}
const isUseLazy = (data): boolean => {
return lazy.value && data && 'loaded' in data && !data.loaded
}
const toggleTreeExpansion = (row: T, expanded?: boolean) => {
instance.store.assertRowKey()
@@ -175,6 +177,7 @@ function useTree<T>(watcherData: WatcherPropsData<T>) {
if (oldExpanded !== expanded) {
instance.emit('expand-change', row, expanded)
}
isUseLazy(data) && loadData(row, id, data)
instance.store.updateTableScrollY()
}
}
@@ -184,7 +187,7 @@ function useTree<T>(watcherData: WatcherPropsData<T>) {
const rowKey = watcherData.rowKey.value
const id = getRowIdentity(row, rowKey)
const data = treeData.value[id]
if (lazy.value && data && 'loaded' in data && !data.loaded) {
if (isUseLazy(data)) {
loadData(row, id, data)
} else {
toggleTreeExpansion(row, undefined)