英文:
How to get selected child node values in a angular mat tree
问题
In angular 14 mat tree, have structure like parent --> child --> sub child . If I select child check box then it select all sub child elements. here I want only sub child selected values when I click on submit button.
here is the stack Blitz example I tried.
Stack Blitz 示例链接
here when I click on submit, it's returning all selected dependents. I want only sub child selected check values.
Please help me. Thanks in advance.
英文:
In angular 14 mat tree, have structure like parent --> child --> sub child . If I select child check box then it select all sub child elements. here I want only sub child selected values when I click on submit button.
here is the stack Blitz example I tried.
https://stackblitz.com/edit/nested-multi-select-tree-demo-nymntq?file=app%2Ftree-nested-overview-example.html,app%2Ftree-nested-overview-example.ts
here when I click on submit, it's returning all selected dependents I want only sub child selected check values.
Please help me. Thanks in advance.
答案1
得分: 0
If hierarchy is up to 3 levels and you want to get sub-child only, you can easily achieve it by customizing your filter method in the submit function.
.filter((descendant) => descendant.isSelected && descendant['children'] === undefined)
英文:
If hierarchy is upto 3 level & you want to get sub-child only, You Can easily get it with customizing your filter method in submit function.
.filter((descendant) => descendant.isSelected && descendant['children'] === undefined)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论