I am having trouble with programmatically selecting an item in a Kendo DropDownList.
I want to preselect an item in a list of regions/languages based on the current culture. I have created the following, but the item is not being preselected (at least visually).
The HTML:
The XML:
The JavaScript:
// === LOCALIZATION DROPDOWNLIST ===
var template_localization_dropdownlist = kendo.template('<
img
src
=
"#=image#"
style
=
"width: 16px; height: 11px; border-width: 0px;"
/> #=display_name#');
$(document).ready(function () {
var selected_culture = get_current_culture()
if (selected_culture == '') {
selected_culture = 'en-US';
}
$("#localization_dropdownlist").width(200).kendoDropDownList(
{
autoBind: false,
dataTextField: "display_name",
dataValueField: "culture_info",
filter: "contains",
template: template_localization_dropdownlist,
dataSource: {
transport:
{
read: "xml/localization.xml"
},
schema:
{
type: "xml",
data: "/localization/language",
model:
{
fields:
{
display_name: "display_name/text()",
local_identifier: "local_identifier/text()",
culture_info: "culture_info/text()",
image: "image/text()"
}
}
}
},
change: function () {
this.value(selected_culture);
}
});
});