mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-09-17 09:16:37 +08:00
feat(hooks): add scrollX computation for total table width in useNaiveTable
This commit is contained in:
parent
9ea56c9b82
commit
358e129765
@ -38,6 +38,13 @@ export function useNaiveTable<ResponseData, ApiData>(options: UseNaiveTableOptio
|
|||||||
getColumns
|
getColumns
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// calculate the total width of the table this is used for horizontal scrolling
|
||||||
|
const scrollX = computed(() => {
|
||||||
|
return result.columns.value.reduce((acc, column) => {
|
||||||
|
return acc + Number(column.width ?? column.minWidth ?? 120);
|
||||||
|
}, 0);
|
||||||
|
});
|
||||||
|
|
||||||
scope.run(() => {
|
scope.run(() => {
|
||||||
watch(
|
watch(
|
||||||
() => appStore.locale,
|
() => appStore.locale,
|
||||||
@ -51,7 +58,10 @@ export function useNaiveTable<ResponseData, ApiData>(options: UseNaiveTableOptio
|
|||||||
scope.stop();
|
scope.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
return {
|
||||||
|
...result,
|
||||||
|
scrollX
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
type PaginationParams = Pick<PaginationProps, 'page' | 'pageSize'>;
|
type PaginationParams = Pick<PaginationProps, 'page' | 'pageSize'>;
|
||||||
|
Loading…
Reference in New Issue
Block a user