I am displaying primeng P-tree SelectionMode checkbox of (parent and child nodes) datas, after selection of nodes , I am filtering the selection property to get the ids of selected nodes but On load of screen how can i set tree nodes checked true with the help of ids.
I am attaching the stackblitz url for reference :- https://stackblitz.com/edit/primeng-treeselection-demo-ewe5tq?file=src%2Fapp%2Fapp.component.ts
Please help on these issue
Thanks in advance
With [(selection)]="selectedModulePermissions" we can give what is already selected. I'm sure you can think of a better way to pre-check what you want but for a simple demo this should do.
ngOnInit() {
this.defaultSelected()
}
defaultSelected() {
this.selectedModulePermissions.push(this.modulePagePermissions[1])
this.selectedModulePermissions.push(this.modulePagePermissions[0].children[0])
}
Working example: https://stackblitz.com/edit/primeng-treeselection-demo-wuapns?file=src%2Fapp%2Fapp.component.ts