Check out the Kendo code snippet below for a dropdown control.
I'm currently facing an issue where I am trying to display a "Please select" option in the dropdown. This code works perfectly fine for all other dropdowns except for this specific one. The option displays as part of the dropdown list, but not when the dropdown loads initially. I have even tried closing and reopening Visual Studio, and clearing browser history, but nothing seems to fix the problem.
function getRC(rcid) {
for (var i = 0; i < ddRCpicklist.length; i++) {
if (ddRCpicklist[i].rcID === rcid) {
return ddRCpicklist[i].RootCause;
}
}
return 'No value matched';
}
function RootCauseDropDownEditor(container, options) {
if (options.model.Name !== null) {
var ddRC= $('<input id="ddRootCause" required data-text-field="RootCause" data-value-field="rcID" data-change="ddRootCauseSelect" data-bind="value:' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
index:0,
autoBind: false,
dataSource: { data: ddRCpicklist },
optionLabel: "--Please Select--"
}).data("kendoDropDownList");
}
}
function ddRootCauseSelect(e) {
ddValRootCause = $("#ddRootCause").val();
alert(ddValRootCause);
}