The NodeService provides methods to retrieve hierarchical node data, typically used for populating tree or treeTable components. It supports both synchronous data retrieval and asynchronous Promise-based retrieval.
Available Methods
getTreeNodes(): Returns a Promise that resolves to an array of tree nodes. Each node contains key, label, data, icon, and an optional children array.getTreeTableNodes(): Returns a Promise that resolves to an array of tree table nodes. Each node contains a key, a data object (containing properties like name, size, and type), and an optional children array.
Node Structure
For standard trees, nodes follow this shape:
{
key: string;
label: string;
data?: string;
icon?: string;
children?: Array<Node>;
}
For tree tables, nodes follow this shape:
{
key: string;
data: {
name: string;
size: string;
type: string;
};
children?: Array<Node>;
}
import { NodeService } from '@/service/NodeService';
// Fetching tree nodes
const nodes = await NodeService.getTreeNodes();
// Fetching tree table nodes
const tableNodes = await NodeService.getTreeTableNodes();