TreePaginationMode Type
Controls what rowCount represents in a tree data provider — either all currently-visible nodes ('all') or only root-level nodes ('root'). This determines how the total page count is calculated.
Set paginateBy in the constructor options of any tree provider.
import { CAPITreeServerDataProvider, CTreeClientDataProvider } from '@katlux/providers'
import type { TreePaginationMode } from '@katlux/providers'
// --- 'all' mode (default) ---
// rowCount = total number of all currently visible nodes
// (roots + expanded children). Page count is based on this.
// Best when you want consistent page sizes regardless of expansion state.
const allModeProvider = new CAPITreeServerDataProvider({
paginateBy: 'all',
pageSize: 20
})
// --- 'root' mode ---
// rowCount = number of root-level nodes only.
// Page count is based on root nodes. Children don't count toward pagination.
// Best for category trees where you want exactly N top-level items per page.
const rootModeProvider = new CTreeClientDataProvider({
paginateBy: 'root',
pageSize: 10
})
// Explicit typing
const mode: TreePaginationMode = 'root'
const provider = new CAPITreeServerDataProvider({ paginateBy: mode })
// On the server side (tree-api-server-side) — paginateBy arrives as a string:
const paginateBy = (query.paginateBy as TreePaginationMode) ?? 'all'
// Use it to decide whether rowCount counts all nodes or only roots:
const rowCount = paginateBy === 'root'
? await db.taxonomy.countRoots()
: await db.taxonomy.countVisible(expandedNodes)
export type TreePaginationMode = 'all' | 'root'
| Value | rowCount represents | Best for |
|---|
| 'all' | All currently visible nodes (roots + all expanded children combined) | Trees where children count toward page limits; consistent page sizes |
| 'root' | Root-level nodes only — children do not count | Category / department trees where you want a fixed number of top-level items per page |