Posted 5 March 2019, 6:18 am EST
I have seen a couple of people posting the problem with first item get selected for inital value but not seeing any resolution for this issue. Has this been resolved?
I also have similar problem when swithing itemsSource.
In the following example I can set ngModelSelectedValue = null so inital value can be empty when this component is rendered but once I click on the switch button it does select the first item even I set ngModelSelectedValue = null again
<wj-auto-complete style="width:100%;"
[itemsSource]="data"
[displayMemberPath]="'country'"
[selectedValuePath]="'id'"
[(ngModel)]="ngModelSelectedValue">
</wj-auto-complete>
<a href="#" (click)="switch()" >Switch source</a>
//component
constructor(private dataSvc: DataService, private dataSvr2: DataSvc) {
this.data = new wjCore.CollectionView(this.dataSvr2.getData(50));
}
switch(){
this.data = new wjCore.CollectionView(this.dataSvr2.getData(4));
this.ngModelSelectedValue = null;
console.log('switching.....');
}
//service
getData(count: number): wjCore.ObservableArray {
var countries = 'US,Germany,UK,Japan,Italy,Greece'.split(','),
data = new wjCore.ObservableArray();
for (var i = 0; i < count; i++) {
console.log( i + ' '+ countries[i % countries.length]);
data.push({
id: i,
country: countries[i % countries.length],
date: new Date(2014, i % 12, i % 28),
amount: Math.random() * 10000,
selected: i % 2 == 0,
disabled: i % 4 == 0
});
}
return data;
}
Any workaround with this?
