gpt4 book ai didi

angular - Kendo UI TreeView 与复选框一起被锁定

转载 作者:行者123 更新时间:2023-12-02 10:07:30 24 4
gpt4 key购买 nike

当我在 Treeview 中使用 isChecked 函数时,所有复选框都被锁定并且无法更改

public data: any[] = [
{ id: 1, isChecked: true, text: 'Furniture' },
{ id: 2, isChecked: false, text: 'Tables & Chairs' },
{ id: 3, isChecked: true, text: 'Sofa 1' },
{ id: 4, isChecked: false, text: 'Sofa 2' }
];

public isChecked = (dataItem: any, index: string): CheckedState => {
if (dataItem.isChecked === true) {
return 'checked';
}
return 'none';
}

HTML:

<kendo-treeview [nodes]="data" textField="text" kendoTreeViewExpandable kendoTreeViewCheckable [checkBy]="'id'" [isChecked]="isChecked">
</kendo-treeview>

demo

最佳答案

您可以通过将 (checkedChange) 事件添加到您的kendo-treeview

<kendo-treeview [nodes]="data" textField="text" (checkedChange)="checkChagne($event)" kendoTreeViewExpandable kendoTreeViewCheckable [checkBy]="'id'" [isChecked]="isChecked">
</kendo-treeview>


public checkChagne($event) {
$event.item.dataItem.isChecked = !$event.item.dataItem.isChecked;
}

关于angular - Kendo UI TreeView 与复选框一起被锁定,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54823417/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com