Skip to main content

useCASharePointTreeView

@spartanfx/react v1.2.2


@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

PropertyTypeDescription
fieldMappingICATreeViewFieldMappingColumn mapping.
modeTreeViewHierarchyModeHierarchy model — 'parentId' (self-lookup) or 'path' (library).
serviceICATabularService<CATreeRecord, string>Generated tabular service from pac code add-data-source.

Options

PropertyTypeDescription
autoRefresh?booleanEnable auto-refresh after mutations (default: true).
cacheDuration?numberCache TTL for read results in ms (default: 60_000).
debug?booleanEnable verbose console logging (default: false).
odataFilter?stringOptional OData $filter expression.
orderColumn?stringOptional $orderby column.
retryPolicy?ICARetryPolicyRetry policy for transient failures.
rowLimit?numberMaximum records per fetch (default: 5000).

Events & callbacks

PropertyTypeDescription
onError?(error) => voidError callback. Called for every operational failure.
onNotify?CANotifyFnNotification callback. If omitted, hook errors surface via error state only.

Full type reference: ICATreeViewBaseConfig

Returns

ICATreeViewReturn

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} />;