TTreePageDataHandler Type
The function signature that server-side tree providers call to load data. It extends TPageDataHandler with a fifth treeParams argument carrying the full tree state needed for server-side hierarchy resolution.
Usage Example
Assign a handler via setPageDataHandler in a server-side tree provider.
TypeScript
import { CTreeServerDataProvider } from '@katlux/providers/data'
import type { TTreePageDataHandler, IDataResult, IDataFilter, IDataSort, TreePaginationMode } from '@katlux/providers'
const provider = new CTreeServerDataProvider()
const myHandler: TTreePageDataHandler = async (
currentPage: number,
pageSize: number,
filter: IDataFilter,
sortList: IDataSort[],
treeParams: {
expandedNodes: (string | number)[],
parentKey: string,
idKey: string,
paginateBy: TreePaginationMode,
expandedByDefault: boolean
},
options?: { disableCache?: boolean }
): Promise<IDataResult> => {
const { expandedNodes, parentKey, idKey, paginateBy } = treeParams
// Fetch root nodes + children of expanded nodes
const result = await db.taxonomy.fetchVisible({
expandedNodes,
parentKey,
idKey,
page: currentPage,
size: pageSize
})
return {
rowCount: result.total,
rows: result.items
}
}
await provider.setPageDataHandler(myHandler)Signature
TypeScript
type TTreePageDataHandler = (
currentPage: number,
pageSize: number,
filter: IDataFilter,
sortList: IDataSort[],
treeParams: {
expandedNodes: (string | number)[],
parentKey: string,
idKey: string,
paginateBy: TreePaginationMode,
expandedByDefault: boolean
},
options?: { disableCache?: boolean }
) => IDataResult | Promise<IDataResult>Parameters
| Parameter | Type | Description |
|---|---|---|
| currentPage | number | 1-based page index. |
| pageSize | number | Number of records per page. |
| filter | IDataFilter | Active filter. May be null when no filter is applied. |
| sortList | IDataSort[] | Active sort descriptors. Empty array when no sort is applied. |
| treeParams | object | Tree state options. See properties below. |
| options?.disableCache | boolean | When true, the handler should bypass any caching and fetch fresh data. |
Return Value
Must return (or resolve to) an IDataResult object containing rows and rowCount.
treeParams Properties
The fifth argument is an object with the following tree-specific fields:
| Property | Type | Description |
|---|---|---|
| expandedNodes | (string | number)[] | IDs of all nodes currently expanded by the user. Fetch root nodes plus the direct children of these IDs. |
| parentKey | string | Field name on each row that holds the parent reference. Mirrors the constructor option. |
| idKey | string | Field name on each row used as the unique node identifier. Mirrors the constructor option. |
| paginateBy | TreePaginationMode | Whether rowCount should reflect all visible nodes ('all') or only root-level nodes ('root'). |
| expandedByDefault | boolean | Whether all nodes should be considered expanded. When true, return all nodes regardless of expandedNodes. |