checked property is not setting to true inside treeviewitem of a filtered result in ngx-treeview component

1k Views Asked by At

My config:

config = TreeviewConfig.create({
hasAllCheckBox: false,
hasFilter: true,
hasCollapseExpand: false,
decoupleChildFromParent: true,
maxHeight: 400
});

I am using the inbuilt filter to find specific items in tree structure. But when I am selecting (selecting the checkbox) an item from the filtered tree structure, the checked property for that particular treeviewitem is not setting to true in the treeviewItem collection. How can resolve this issue?

1

There are 1 best solutions below

0
On

Let's assume you have a Treeview item list named as treeList and you have a set of items you want to check in an array named checkList.

All you have to do is to iterate through the array list of specific IDs that is to be checked in the tree and use the TreeviewHelper.findItemInList and checked properties to set those items checked.

for (let i = 0; i < this.checkList.length; i++) {
    TreeviewHelper.findItemInList(this.treeList, this.checkList[i]).checked = true;
}

For further reference, you can check this.