Commit d20c3a2e authored by XieZhiXiong's avatar XieZhiXiong

feat: 新增 beforePaginationChange 属性

parent c2e9d6f4
......@@ -35,6 +35,7 @@ const NormalTable: React.ForwardRefRenderFunction<NormalTableRefHandleType, Norm
onPaginationChange,
full,
renderFootContent,
beforePaginationChange,
...restProps
} = props;
......@@ -99,7 +100,11 @@ const NormalTable: React.ForwardRefRenderFunction<NormalTableRefHandleType, Norm
}
}, [props.dataSource]);
const handlePaginationChange = (page: number, size: number) => {
const handlePaginationChange = async (page: number, size: number) => {
if (beforePaginationChange) {
const flag = await beforePaginationChange?.(page, size);
if (!flag) return;
}
// 内部自己维护 page、size
if (!('current' in pagination)) {
setCurrent(page);
......
......@@ -87,6 +87,10 @@ export interface NormalTableProps<T> extends Omit<TableProps<T>, 'pagination'> {
* 渲染底部内容
*/
renderFootContent?: () => React.ReactNode,
/**
* 分页器改变触发的钩子,若返回 false 则停止触发请求
*/
beforePaginationChange?: (nextPage: number, nextSize: number) => boolean | Promise<boolean>,
}
export interface EditableCellProps {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment