[Feature Request] treenode link to parent
Would be very useful if each TreeNode in a TreeNode[] is able to access the parent node, otherwise we would need to define a new Node structure and do it manually. I believe that the implementation can simplify operations with trees.
@sdmoralesma - TreeNode is just an interface, so when you build out your TreeNode objects, can you just add a parentFolder property?
Well given that the definition of TreeNode from PrimeNG is:
export interface TreeNode {
label?: string;
data?: any;
icon?: any;
expandedIcon?: any;
collapsedIcon?: any;
children?: TreeNode[];
leaf?: boolean;
}
I defined my custom type like:
export interface FileNode extends TreeNode {
id:string;
parentId?:string;
}
And the Tree will still work because FileNode is a TreeNode.
You can have some idea of how to make your own implementation here: filemanager.component.ts with a live demo: javalab.co
Should be better handled on app side by a custom interface that extends our TreeNode as mentioned above.