从该示例中我几乎得到了1到1棵树:https : //stackblitz.com/angular/nnxeaxmrdob?file=src%2Fapp%2Ftree-checklist-example.ts
我需要获取所有选定的值和不确定的值。我知道,所有选定值保持在checklistSelection变量,然而,当选择了整个子节点,我已经得到了家长和孩子的阵列,但在只选择一些孩子,然后我没有问题父母。
因此,我又一次如何获得选定且不确定的值?
在示例中,您可以使用
const partial=this.treeControl.dataNodes
.filter(x=>this.descendantsPartiallySelected(x))
console.log(this.checklistSelection.selected,partial)
哪里(*)
descendantsPartiallySelected(node: TodoItemFlatNode): boolean {
const descendants = this.treeControl.getDescendants(node);
const result = descendants.some(child => this.checklistSelection.isSelected(child));
return result && !this.descendantsAllSelected(node);
}
(*)您在示例中尚未使用此功能
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句