我使用Kendo-angular库。当用户在我的下拉列表中选择一个项目时,将触发selectionChange事件,并根据某些条件我要取消更改事件并在下拉列表中恢复为先前选择的值。
这可以通过kendo下拉列表组件实现吗?
<kendo-dropdownlist
[data]="services"
[textField]="'defaultLabel'"
[valueField]="'id'"
[(ngModel)]="selectedService"
placeholder="Select a service"
(valueChange)="onServiceChanged($event)">
</kendo-dropdownlist>
onServiceChanged(event) { }
//event is the actual selected value, not the event
答案 0 :(得分:0)
我找到了解决方法:
<kendo-dropdownlist #dropdown
(valueChange)="valueChange($event, dropdown)">
</kendo-dropdownlist>
valueChange(value, dropDownControl: DropDownListComponent) {dropDownControl.writeValue("old value");}
答案 1 :(得分:-1)
检查文档中的事件列表 https://www.telerik.com/kendo-angular-ui/components/dropdowns/dropdownlist/#toc-events
public valueChange(value: any): void {
// Your condition here
this.log('valueChange', value);
}