Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The filtering function of angular tree-component does not apply to multiple child nodes. #869

Open
kimselim opened this issue Nov 20, 2020 · 0 comments

Comments

@kimselim
Copy link

kimselim commented Nov 20, 2020

There are several child nodes in one node as shown below.
According to the manual in the tutorial, grandchild2-1-1 is not searched, only child2 is searched.
Is it impossible to search with the functions in the manual?

image

`filterTree() {
let foundResults: TreeNode[] = [];

this.treeComponent.treeModel.filterNodes((node: TreeNode) => {
  const nodeName = node.data.name;
  const searchValue = this.searchChartWord;
  const nodeFound = nodeName.includes(searchValue);

  if (nodeFound && node.hasChildren) {
    for (let child of node.children) {
      if(child.hasChildren){
        foundResults.push(node);
      }
    }
    foundResults.push(node);
  }
  return nodeFound;
});

foundResults.forEach((item) => {
  item.children.forEach((child) => {
    child.show();
    child.ensureVisible();
  });
});

}`

code:
<tree-root #tree [nodes]="nodes" [focused]="true"> <ng-template #treeNodeTemplate let-node="node" let-index="index"> <input class="pt-1"type="checkbox" [indeterminate]="node.data.indeterminate" [checked]="node.data.checked"> <span class="pl-1" (click)="treeMembers(node.data)">{{node.data.name}}</span> </ng-template> </tree-root>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant