我没有在kendo下拉列表中获得占位符。任何人都建议我寻求解决方案

时间:2014-11-24 06:35:58

标签: kendo-ui kendo-dropdown

我没有在kendo下拉列表中获得占位符。任何人都可以建议我寻求解决方案

HTML

<input id="inp1" type="text"/>

的JavaScript

var data1 = [ //this part is related to the above html tag
    {text: "org1", value: "1", color: "#a8a9aa", selected:true },
    {text: "org2", value: "2", color: "#000", selected: false },
    {text: "org3", value: "3", color: "#000", selected: false },
    {text: "org4", value: "4", color: "#000", selected: false },
    {text: "org5", value: "5", color: "#000", selected: false }
];
$("#inp1").kendoDropDownList({      
    dataTextField : "text",
    dataValueField: "value",
    dataSource    : data1,
    placeholder:"select your option",
    select        : onSelect,
    value         :1
});

1 个答案:

答案 0 :(得分:9)

kendo下拉窗口小部件没有“占位符”属性。相反,你可以通过放置一个 “optionLabel”property.i.e。

 var data1 = [ //this part is related to the above html tag
                 {text: "org1", value: "1", color: "#a8a9aa", selected:true },
                 {text: "org2", value: "2", color: "#000", selected: false },
                 {text: "org3", value: "3", color: "#000", selected: false },
                 {text: "org4", value: "4", color: "#000", selected: false },
                 {text: "org5", value: "5", color: "#000", selected: false }
            ];

   $("#inp1").kendoDropDownList({      
                  dataTextField : "text",
                  dataValueField: "value",
                  dataSource    : data1 ,
                  optionLabel   : "select your option",
                  select        : onSelect
           });

确保在javascript中定义“onSelect”功能。 供参考check here