useCASharePointTreeView
@spartanfx/react / codeapps / useCASharePointTreeView
Function: useCASharePointTreeView()
function useCASharePointTreeView(config): ICATreeViewReturn;
Power Apps Code Apps TreeView hook backed by a SharePoint list or document
library. Consumes a generated SharePoint service produced by
pac code add-data-source -a shared_sharepointonline -t <ListName> -d <siteUrl>.
Configuration
Required
| Property | Type | Description |
|---|---|---|
fieldMapping | ICATreeViewFieldMapping | Column mapping. |
mode | TreeViewHierarchyMode | Hierarchy model — 'parentId' (self-lookup) or 'path' (library). |
service | ICATabularService<CATreeRecord, string> | Generated tabular service from pac code add-data-source. |
Options
| Property | Type | Description |
|---|---|---|
autoRefresh? | boolean | Enable auto-refresh after mutations (default: true). |
cacheDuration? | number | Cache TTL for read results in ms (default: 60_000). |
debug? | boolean | Enable verbose console logging (default: false). |
odataFilter? | string | Optional OData $filter expression. |
orderColumn? | string | Optional $orderby column. |
retryPolicy? | ICARetryPolicy | Retry policy for transient failures. |
rowLimit? | number | Maximum records per fetch (default: 5000). |
Events & callbacks
| Property | Type | Description |
|---|---|---|
onError? | (error) => void | Error callback. Called for every operational failure. |
onNotify? | CANotifyFn | Notification callback. If omitted, hook errors surface via error state only. |
Full type reference:
ICATreeViewBaseConfig
Returns
Example
import { TreeViewTestService } from './generated/services/TreeViewTestService';
import { useCASharePointTreeView } from '@spartanfx/react/codeapps';
const tree = useCASharePointTreeView({
service: TreeViewTestService as never,
mode: 'parentId',
fieldMapping: { id: 'ID', label: 'Title', parentId: 'Parent' },
});
return <TreeView items={tree.items} schema={tree.schema} />;