Primeng: Tree - Treetable default selection is not updating the checkboxes

Created on 5 Aug 2017  路  6Comments  路  Source: primefaces/primeng

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.

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

All 6 comments

3285 i have the same issue...

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cyberrranger picture cyberrranger  路  3Comments

jisqaqov picture jisqaqov  路  3Comments

jisqaqov picture jisqaqov  路  3Comments

Helayxa picture Helayxa  路  3Comments

mitosandov picture mitosandov  路  3Comments