我已经基于“清晰树”视图构建了一个组件,
我选择\取消选择折叠的父节点时遇到问题, 它不会影响子节点的选择, 当我扩大他的职位时,他又被选中\取消选中。
有人可以帮忙吗?
以下是视图:
<clr-tree-node class="tree-root" [(clrSelected)]="tree.selected" id="statusTreeFilter">
{{tree.name}}
<ng-template [(clrIfExpanded)]="tree.expanded">
<clr-tree-node *ngFor="let group of tree.childs" [(clrSelected)]="group.selected">
<span>{{group.name}}</span>
<ng-template [(clrIfExpanded)]="group.expanded">
<clr-tree-node *ngFor="let status of group.childs" [(clrSelected)]="status.enable">
<span>{{status.name}}</span>
<ng-template></ng-template>
</clr-tree-node>
</ng-template>
</clr-tree-node>
</ng-template>
和数据:
let tree = {
"name": "All",
"selected": true,
"expanded": false,
"childs": [
{
"name": "Generate",
"selected": true,
"expanded": false,
"childs": [
{
"name": "Init",
"enable": true
},
{
"name": "Generating",
"enable": true
},
{
"name": "Generated",
"enable": true
}
]
},
{
"name": "Printing",
"selected": true,
"expanded": false,
"childs": [
{
"name": "Printing",
"enable": true
}
]
},
{
"name": "Finalized",
"selected": true,
"expanded": false,
"childs": [
{
"name": "Completed",
"enable": true
},
{
"name": "Cancelled",
"enable": true
}
]
}
]
}
答案 0 :(得分:0)
您的根节点需要指向selected
对象的布尔selection
属性。您正在将clrSelected绑定设置为整个对象,这会导致此行为。
<clr-tree-node class="tree-root" [(clrSelected)]="selection.selected" id="statusTreeFilter">
这里已完全设置。 https://stackblitz.com/edit/clarity-hmrndh?file=app%2Fapp.component.html
答案 1 :(得分:0)
修复了清晰度1.0(重大更改)