mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user