On passing a TreeNode[] variable to the selection attribute in the p-treetable, the checkboxes are not getting updated as per the selection, allowing the same option to be selected twice.
Still no response from them...
Temp Solution
so i use p-treetable without check bock & place check box in template body & write my own code for tree checkbox check/uncheck part
i was also facing the same issue. so i have used ng-template and then i have taken input type checkbox and then i have one property "isSelected" in json. and while retrieving values i have looped the json in a recursive way and then compare the values from database and my json then i make the same object found "isSelected" property true.
Sample code:
HTML:
{{node.data.groupName}}
</p-column>
</p-treeTable>
JSON:
export class Group {
GroupName: string;
StartDate : string;
isSelected : boolean;
}
Component: i have called this function "setNodeSelecteed()" on the values which i am retrieving from database.
setNodeSelected = function (node, selectGroupName) { // node => this.allGroups
if (node.children && node.children.length > 0) {
for (var i = 0; i < node.children.length; i++) {
this.setNodeSelected(node.children[i], selectGroupName);
}
}
else {
if (node.data.groupName.trim().toLowerCase() === selectGroupName.trim().toLowerCase()) {
node.data.isSelected = true;
}
}
}
Hope this helps you. :)
Tree also has the same problem I guess, will be worked on for upcoming 4.3.
In checkbox mode, when inititing a tree with preselections, also set partialSelected
property on node so that minus icon can be displayed when necessary.
Found a workaround for pre-selection of multiple check-boxes (programmatically) in primeng Tree. You can find working example here: https://github.com/jigneshkhatri/primeng-treenode-preselect
Hi,
This is a very nice workaround, however I think that it should be working two way binding without writing many lines of code.
Can you please fix the bug, I'm trying to do the selection from ts too, with no luck.
Thank you for your great control and big effort.
Best regards,
Chen
Most helpful comment
Found a workaround for pre-selection of multiple check-boxes (programmatically) in primeng Tree. You can find working example here: https://github.com/jigneshkhatri/primeng-treenode-preselect