Created
October 18, 2018 12:25
-
-
Save marekdano/2a98aba3843dfc787fdcf55f941b22a5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Function finds the node you are searching for and expand it and its parent. | |
| * | |
| * @param {TreeNode} node primeng tree node data | |
| * @param {string} propField name of the property you are searching for ex: label | |
| * @param {any} searchValue value you are searching for | |
| */ | |
| filterExpandRecursive( | |
| node: TreeNode, | |
| propField: string, | |
| searchValue: any | |
| ): boolean { | |
| const isMatchSearchField = node[propField] === searchValue; | |
| node.expanded = | |
| node.children && | |
| node.children.length > 0 && | |
| node.children.some(childNode => | |
| this.filterExpandRecursive(childNode, propField, searchValue) | |
| ); | |
| return isMatchSearchField || node.expanded; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment