Reputation: 39
I am using Kendo Combobox to bind certain values in UI.Is it possible to set the first value of the Array as the default value ?.
Upvotes: 1
Views: 2050
Reputation: 686
I know this is almost late for you, Some other can use this.
This is in client side .html file:
<kendo-combobox [data]="SalasType" [valuePrimitive]="true"
[textField]="'name'" (valueChange)="productTypeChange($event)" [valueField]="'id'" [(ngModel)]="selectedValue.id" name="Product Group">
</kendo-combobox>
add this to client .ts file : add this in common file (or you can make this array inside of your .ts)
export const OSSSALELIST = [
{ id: 1, name: 'Product Group' },
{ id: 2, name: 'Product' }
];
call that global constant here,
SalasType = OSSSALELIST;
selectedValue:any;
and in oninit method :enter code here
this.selectedValue=this.SalasType[0];
Upvotes: 1
Reputation: 2262
From Combobox Point of view you can add the first value as selection using following code. This is irrespective of the Angular code. Cause you've not mentioned any code snippet or feature you want to use to achieve that.
$("#targetComboId").kendoComboBox({
dataTextField: "text",
dataValueField: "value",
dataSource: [{
text: "Cotton",
value: "1"
},
{
text: "Polyester",
value: "2"
},
{
text: "Cotton/Polyester",
value: "3"
},
{
text: "Rib Knit",
value: "4"
}
],
index: 0 // Your target value, set it to the index you want
});
This will select and populate the first value in the Combobox. Hope it helps!
Upvotes: 1