@theredhead — Frontend Library - v1.0.0
    Preparing search index...

    Interface ISortableTreeDatasource<T>

    Optional tree sorting capability.

    Implement this interface alongside ITreeDatasource when the datasource supports sorting hierarchical data at all levels (root nodes and their descendants).

    interface ISortableTreeDatasource<T = unknown> {
        getChildren(node: TreeNode<T>): TreeNode<T>[] | Promise<TreeNode<T>[]>;
        getRootNodes(): TreeNode<T>[] | Promise<TreeNode<T>[]>;
        hasChildren(node: TreeNode<T>): boolean;
        sortBy(expression: SortExpression<T> | null): void;
    }

    Type Parameters

    • T = unknown

      The data payload type.

    Hierarchy (View Summary)

    Implemented by

    Index

    Methods

    • Returns the children of the given node.

      The default implementation reads node.children. Override this method to support lazy-loading children from a remote source.

      Parameters

      • node: TreeNode<T>

        The parent node whose children are requested.

      Returns TreeNode<T>[] | Promise<TreeNode<T>[]>

    • Returns the root-level nodes of the tree.

      May return synchronously or as a Promise for lazy-loaded trees.

      Returns TreeNode<T>[] | Promise<TreeNode<T>[]>

    • Returns true if the node has children (or might have children that can be lazy-loaded).

      The default implementation checks node.children?.length > 0.

      Parameters

      Returns boolean

    • Applies a serializable sort expression to the tree datasource.

      The expression describes which properties of the data payload T to sort by. Sorting is applied recursively at all levels (root nodes and all descendants). Subsequent calls to getRootNodes() and getChildren() should return sorted data.

      Pass null to clear sorting and restore the original insertion order.

      Parameters

      • expression: SortExpression<T> | null

        Sort criteria in priority order, or null to clear.

      Returns void