如何在角2中设置kendo-combobox的默认值

如何在角2中设置kendo-combobox的默认值

问题描述:

我正在使用Kendo Combobox绑定UI中的某些值。是否可以将数组的第一个值设置为默认值?如何在角2中设置kendo-combobox的默认值

+0

发布您的代码片段。如何将组合框初始化为选择标签并为其分配值。 –

从Combobox角度来看,您可以使用以下代码添加第一个值作为选择。这与Angular代码无关。因为你没有提到任何你想用来实现的代码片段或功能。

$("#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 
}); 

这将选择并填充Combobox中的第一个值。希望能帮助到你!