Hello
There is a weird behaviour using Kendo.dropdownlist.open() function: In the fully working example below you see 3 defined Kendo DropdownList. As soon as a value is chosen from first dropdownlist it opens the second dropdownlist. Choosing an option of second dropdownlist opens the third dropdownlist. Try this to show you the weird effect:
1. Choose "SUV" from first dropdownlist
2. Choose "Normal" from second dropdownlist
3. Choose "orange" from third dropdownlist.
So far it works fine as it should. Now open the first dropdownlist again and choose "Convertible": The second AND the third dropdownlist will be opened. The third dropdownlist shouldn't be opened! The reason why the third dropdownlist will be opened is caused by resetting the datasource source3 in the change event of dropdownlist1 (took me a while to find that out).
<!DOCTYPE html>
<html lang=
"en"
>
<head>
<meta charset=
"UTF-8"
>
<title>Title</title>
</head>
<body>
<script src=
"http://kendo.cdn.telerik.com/2017.3.1018/js/jquery.min.js"
></script>
<link rel=
"stylesheet"
href=
"http://kendo.cdn.telerik.com/2017.3.1018/styles/kendo.common.min.css"
/>
<link rel=
"stylesheet"
href=
"http://kendo.cdn.telerik.com/2017.3.1018/styles/kendo.blueopal.min.css"
/>
<script src=
"http://kendo.cdn.telerik.com/2017.3.1018/js/kendo.all.min.js"
></script>
<script>
// Define datasources for dropdownlists
var
source1 =
new
kendo.data.DataSource({
data: [
{ id: -1, name:
"Choose type..."
},
{ id: 1, name:
"SUV"
},
{ id: 2, name:
"Convertible"
}
]});
var
source2 =
new
kendo.data.DataSource({
data: [
{ id: -1, name:
"Choose size..."
},
{ id: 1, name:
"Normal"
},
{ id: 2, name:
"Small"
}
]});
var
source3 =
new
kendo.data.DataSource({
data: [
{ id: -1, name:
"Choose color..."
},
{ id: 1, name:
"green"
},
{ id: 2, name:
"blue"
}
]});
$(document).ready(
function
() {
$(
"#dropdownlist1"
).kendoDropDownList({
value: -1,
dataSource: source1,
dataTextField:
"name"
,
dataValueField:
"id"
,
change:
function
() {
// Change options of dropdownlist3
source3.data([
{ id: -1, name:
"Choose color..."
},
{ id:
"Choose type..."
, name:
"orange"
},
{ id:
"Choose type..."
, name:
"brown"
}
]);
$(
"#dropdownlist2"
).data(
"kendoDropDownList"
).open();
}
});
$(
"#dropdownlist2"
).kendoDropDownList({
value: -1,
dataSource: source2,
dataTextField:
"name"
,
dataValueField:
"id"
,
change:
function
() {
$(
"#dropdownlist3"
).data(
"kendoDropDownList"
).open();
}
});
$(
"#dropdownlist3"
).kendoDropDownList({
value: -1,
dataSource: source3,
dataTextField:
"name"
,
dataValueField:
"id"
});
});
</script>
<div id=
"mydiv"
>
<input id=
"dropdownlist1"
style=
'width: 170px;'
/>
<input id=
"dropdownlist2"
style=
'width: 170px;'
/>
<input id=
"dropdownlist3"
style=
'width: 170px;'
/>
</div>
</body>
</html>
(I am aware of cascading dropdownlists but my project goes beyond that so I need to refill datasources by myself).
What needs to be done to avoid the third dropdownlist get opened in such a case?