Here is the Html code to get the selected item value from Kendo AutoComplete widget:
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Untitled</title>
-
- <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2015.3.1111/styles/kendo.common.min.css">
- <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2015.3.1111/styles/kendo.rtl.min.css">
- <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2015.3.1111/styles/kendo.default.min.css">
- <link rel="stylesheet" href="http://kendo.cdn.telerik.com/2015.3.1111/styles/kendo.mobile.all.min.css">
-
- <script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
- <script src="http://kendo.cdn.telerik.com/2015.3.1111/js/angular.min.js"></script>
- <script src="http://kendo.cdn.telerik.com/2015.3.1111/js/jszip.min.js"></script>
- <script src="http://kendo.cdn.telerik.com/2015.3.1111/js/kendo.all.min.js"></script>
- </head>
- <body>
- <div id="example">
- <input id="AutoFill_ID" data-role="autocomplete"
- data-placeholder="Department"
- data-selectable="true"
- data-text-field="name"
- data-bind="value: selectedProduct,
- source: DepartmentSource,
- visible: isVisible,
- enabled: isEnabled,events:{select:AutoComplete_Select}"
- style="width: 100%;" />
- </div>
- <script>
- $(document).ready(function () {
- var department = [
- { name: 'HR', id: 1 },
- { name: 'Infrastructure', id: 2 },
- { name: 'Testing', id: 3 }
-
- ];
-
- var viewModel = kendo.observable({
- DepartmentSource: new kendo.data.DataSource({
- data: department
- }),
- selectedProduct: null,
- isVisible: true,
- isEnabled: true,
- selectedPerson: {},
- AutoComplete_Select: function (e) {
- var item = e.sender.dataItem(e.item.index());
- viewModel.set("selectedPerson", item);
- alert(item.name);
- },
- })
- kendo.bind($("#example"), viewModel);
- })
-
- </script>
- </body>
- </html>