一,先写出万能实例如下:
<div id="dropDownList"></div>
<script>
$("#dropDownList").kendoDropDownList({
dataTextField: "text",
dataValueField: "value",
dataSource: data,
index: 0 // 当前默认选中项,索引从0开始。
});
</script>
二,修改位置。
2.1 change事件是选中值更改的时候才会触发,当下拉框下面的数据为一个的时候,你就无法更改了,这时候我们就用上了select事件,但是select事件是获取的上次选中的值,我们该怎么办??
第一种解决方法,给下拉菜单中添加一条固定的【请选择】的数据,你就可以通过change事件更改选项了
$("#dropDownList").kendoDropDownList({
dataTextField: "text",
dataValueField: "value",
optionLabel:“请选择”,
dataSource: data,
index: 0 // 当前默认选中项,索引从0开始。
change:function(e){
console.log(e);
}
});
**第二种方法,使用select事件**
$("#dropDownList").kendoDropDownList({
dataTextField: "text",
dataValueField: "value",
dataSource: data,
index: 0 // 当前默认选中项,索引从0开始。
select:function(e){
var needitem = e.sender.dataItem(e.item);
var text= needitem.text;
var value= needitem.value;
}
});
三,纯手工码字,书写不易,你懂得.