Skip to content

toCursorPagination

function toCursorPagination(input): object;

Defined in: filters/tanstack-table.ts:778

Turn the table’s index-based pagination into a cursor request, using the cursors recorded so far (rememberCursor). The request always walks forward from the cursor of the page before. A pageIndex the stack can’t reach yet (a deep link, a jump) is clamped to the furthest known page and returned as pageIndex, so you can correct the table state.

Parameter Type
input { cursors: TableCursors; pagination: TablePaginationState; }
input.cursors TableCursors
input.pagination TablePaginationState

object

Name Type Defined in
pageIndex number filters/tanstack-table.ts:781
pagination CursorPagination filters/tanstack-table.ts:781
import { toCursorPagination } from "@xtandard/lib/filters/tanstack-table";
toCursorPagination({ pagination: { pageIndex: 0, pageSize: 20 }, cursors: [] });
// → { pagination: { type: "cursor", limit: 20, cursor: null, direction: "forward" }, pageIndex: 0 }
toCursorPagination({ pagination: { pageIndex: 2, pageSize: 20 }, cursors: ["c1", "c2"] });
// → { pagination: { type: "cursor", limit: 20, cursor: "c2", direction: "forward" }, pageIndex: 2 }
toCursorPagination({ pagination: { pageIndex: 5, pageSize: 20 }, cursors: ["c1"] });
// → { pagination: { type: "cursor", limit: 20, cursor: "c1", direction: "forward" }, pageIndex: 1 }