Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ [Feature]: 建议对d-casader组件增加回调函数控制是否可选 #338

Closed
guanghe1990 opened this issue Nov 15, 2023 · 3 comments

Comments

@guanghe1990
Copy link

What problem does this feature solve

使用d-cascader组件时,有时虽然是叶子节点(isLeaf:true),但是业务逻辑上需要禁止选择。建议组件增加一个回调函数,返回true则选择成功,返回false则选择失败。或者直接在CascaderItem类型上面增加一个属性canSelectable:boolean;用来控制是否可以选择。

What does the proposed API look like

如果增加回调函数:
<d-cascader
[options]="options"
[(ngModel)]="value"
[canSelectable]=canSelect

canSelect(value:number|string):boolean;

或者在CascaderItem类型增加canSelectable:boolean属性:
interface CascaderItem {
label: string;
value: number | string;
isLeaf?: boolean;
children?: CascaderItem[];
canSelectable:boolean
disabled?: boolean;
icon?: string;
// 用户可以传入自定义属性,并在dropDownItemTemplate中使用
[prop: string]: any;
}

@foolmadao
Copy link

没理解,你要禁止选择直接设置节点disabled就可以吧

@guanghe1990
Copy link
Author

guanghe1990 commented Mar 10, 2024

没理解,你要禁止选择直接设置节点disabled就可以吧

比如员工列表, 有些部门没有员工, 那叶子节点就是部门, 应该是不能选择, 而总不能把所有的部门都设置为disable

@foolmadao
Copy link

没理解,你要禁止选择直接设置节点disabled就可以吧

比如员工列表, 有些部门没有员工, 那叶子节点就是部门, 应该是不能选择, 而总不能把所有的部门都设置为disable

禁用是针对单个节点,而不是某一类,数据在你手里,你把没有子的部门禁用了就好。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants