I have defined kendocombox in my html like below
<input id="selFrameworkVersion" style="width: 210px" data-bind="kendoComboBox: { dataTextField: 'Name', dataValueField: 'Id', data: $root.versionListByProductType, value: $root.editFrameworkVersion, optionsCaption: 'Select Version...' }" />
The combobox loads correctly and sets value but when it doesnt set focus to proper item in list. See image below
You can see value is 5.5.1 but it sets to 5.4 which is first item in list. I now know that why its happening. On my combobox you can see that i have value set as $root.editFrameworkVersion. In my view model i use subscribe event on that value. See code below
self.editFrameworkVersion.subscribe(function (value) {
var combobox = $("#selFrameworkVersion").data("kendoComboBox");
var callback = function (data) {
self.editOnlyAlternativeVersions(self.versionListByProductType());
combobox.select(function (dataItem) {
return dataItem.Name === value;
});
self.editOnlyAlternativeVersions.remove(function (data) {
return parseInt($("#selFrameworkVersion").attr('value')) === parseInt(data.Id());
});
};
loadVersionListByProductType(self.editProductType().Id(), callback);
});
I use this subscribe event to do some logic. In this event i am calling WCF service which loads value again in that combobox and thats why its always set to first value. But its required for me to call that service for some logic. Then i added code in that subscribe event which you already have seen above
combobox.select(function (dataItem) {
return dataItem.Name === value;
});
This code sets the value correctly but only if combobox loses focus. What should i do?