daily pastebin goal
44%
SHARE
TWEET

Untitled

a guest Oct 18th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top