当第一个下拉列表基于该值更改时,我有2个kendo下拉列表。我希望更新第二个下拉列表,并且默认情况下应选择第一个值,因此基本上第二个下拉列表应使用新值刷新。 下面是堆叠闪电战。
https://stackblitz.com/edit/angular-nd9cpn-xpah4u?file=app/app.component.ts
答案 0 :(得分:1)
您可以像这样使用valuechange
事件:(valueChange)="handleTypeChange($event)"
import { Component, OnInit } from '@angular/core';
@Component({
selector: 'my-app',
template: `
<kendo-dropdownlist [data]="['normal', 'smooth']" [(ngModel)]="style" (valueChange)="handleTypeChange($event)">
</kendo-dropdownlist>
<kendo-dropdownlist [(ngModel)]="secondaryListChoice"
[data]="secondaryList"
[textField]="'text'"
[valueField]="'value'"
>
</kendo-dropdownlist>
<kendo-chart>
<kendo-chart-series>
<kendo-chart-series-item [style]="style" type="scatterLine"
[data]="data"
[markers]="{ visible: false }">
</kendo-chart-series-item>
</kendo-chart-series>
</kendo-chart>
`
})
export class AppComponent implements OnInit {
public style: string = 'normal';
public secondaryListChoice: string = '';
public data: any[] = [
[0, 20], [1, 1], [2, 18], [3, 3],
[4, 15], [5, 5], [6, 10], [7, 6],
[8, 9], [9, 6], [10, 10], [11, 5],
[12, 13], [13, 3], [14, 16], [15, 1],
[16, 19], [17, 1], [18, 20], [19, 2],
[20, 18], [21, 5], [22, 12], [23, 7],
[24, 10], [25, 8]
];
public secondaryList : Array<any> = [
{ text: 'value1', value: 'value2' },
{ text: 'value2', value: 'value2' },
];
ngOnInit(){
}
handleTypeChange(event) {
console.log(event);
if (this.style === 'normal') {
this.secondaryList = [
{ text: 'value1', value: 'value2' },
{ text: 'value2', value: 'value2' },
{ text: 'value3', value: 'value3' },
{ text: 'value4', value: 'value4' },
{ text: 'value5', value: 'value5' }];
}
if(this.style==='smooth'){
this.secondaryList = [
{ text: 'zzvalue5', value: 'zzvalue5' },
{ text: 'zzvalue5', value: 'zzvalue5' }];
}
}
}
此处有效的实现方式:https://stackblitz.com/edit/angular-nd9cpn-bvsqrj?file=app/app.component.ts