primeng icon indicating copy to clipboard operation
primeng copied to clipboard

[Feature Request] treenode link to parent

Open sdmoralesma opened this issue 10 years ago • 3 comments

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 avatar May 28 '16 11:05 sdmoralesma

@sdmoralesma - TreeNode is just an interface, so when you build out your TreeNode objects, can you just add a parentFolder property?

JakeSummers avatar Jul 29 '16 21:07 JakeSummers

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

sdmoralesma avatar Jul 29 '16 21:07 sdmoralesma

Should be better handled on app side by a custom interface that extends our TreeNode as mentioned above.

cagataycivici avatar Nov 13 '16 10:11 cagataycivici