I am using knock out kendo autocomplete in my application. I want to get the value field of the selected autocomplete. Below is the fiddle for the auto complete. Instead of text I want to display id.
Javascript code:
var ViewModel = function() {
this.choices = ko.observableArray([
{ id: "1", name: "apple"},
{ id: "2", name: "orange"},
{ id: "3", name: "banana"}
]);
this.selectedChoice = ko.observable();
};
ko.applyBindings(new ViewModel());
HTML:
<input data-bind="kendoAutoComplete: { dataTextField: 'name',
dataValueField:'id',
data: choices,
value: selectedChoice }" />
Selected: <strong data-bind="text: selectedChoice"> </strong>