Guest User

Untitled

a guest
Oct 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. /**
  2. * Function finds the node you are searching for and expand it and its parent.
  3. *
  4. * @param {TreeNode} node primeng tree node data
  5. * @param {string} propField name of the property you are searching for ex: label
  6. * @param {any} searchValue value you are searching for
  7. */
  8. filterExpandRecursive(
  9. node: TreeNode,
  10. propField: string,
  11. searchValue: any
  12. ): boolean {
  13. const isMatchSearchField = node[propField] === searchValue;
  14. node.expanded =
  15. node.children &&
  16. node.children.length > 0 &&
  17. node.children.some(childNode =>
  18. this.filterExpandRecursive(childNode, propField, searchValue)
  19. );
  20. return isMatchSearchField || node.expanded;
  21. }
Add Comment
Please, Sign In to add comment