fix(grid): stop infinite scroll at exact total

This commit is contained in:
zipg authored and GitHub committed 2026-07-29 00:59:37 +08:00
1 parent a8592af97a
commit 234f26ada8
4 files changed
+52 -2

No files matched your search

@@ -21,6 +21,14 @@ export interface CompleteLocalDataGridResultOptions {
hasMore?: boolean;
}
export interface CanFetchNextDataGridSegmentOptions {
hasMore?: boolean;
loadedRowCount: number;
pageSize: number;
totalRowCount?: number;
allRowsLoaded?: boolean;
}
export function resolveDataGridPaginationTotal(options: { paginationTotalRowCount?: number; serverKnownTotalRowCount?: number; totalRowCountIsExact: boolean }): number | undefined {
if (options.paginationTotalRowCount !== undefined) return options.paginationTotalRowCount;
return options.totalRowCountIsExact ? options.serverKnownTotalRowCount : undefined;
@@ -55,3 +63,15 @@ export function canGoNextDataGridPage(options: CanGoNextDataGridPageOptions): bo
return options.rowCount >= pageSize;
}
export function canFetchNextDataGridSegment(options: CanFetchNextDataGridSegmentOptions): boolean {
if (options.hasMore === true) return true;
const totalRowCount = options.totalRowCount;
if (typeof totalRowCount === "number" && Number.isFinite(totalRowCount) && totalRowCount >= 0) {
return options.loadedRowCount < totalRowCount;
}
if (options.allRowsLoaded === true) return false;
return options.loadedRowCount >= Math.max(1, options.pageSize);
}