Per the documentation I am trying to add Events to the autocomplete helper so I can lookup the value of the selected item (as seen in this post), but when doing so am getting the following error on line 10:
Here is the PartialView
Call from View:
Controller:
Compilation ErrorDescription: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: CS1977: Cannot use a lambda expression as an argument to a dynamically dispatched operation without first casting it to a delegate or expression tree typeSource Error:Line 8: .DataTextField("DisplayName")Line 9: .BindTo(Model)Line 10: .Events(e => e
.Change("autocomplete_change"))Line 11: .Placeholder("Select Customer...")Line 12: .HtmlAttributes(new {@class = "filter"})@using Kendo.Mvc.UI;@model IEnumerable<OTIS.AppServ.Shared.ViewModels.ddlOptions>@(Html.Kendo().AutoComplete() .Name(ViewBag.ControlId) .Filter("startswith") .DataTextField("DisplayName") .BindTo(Model) .Events(e => e
.Change("autocomplete_change")) .Placeholder("Select Customer...") .HtmlAttributes(new {@class = "filter"}) )<script> function autocomplete_change() { var autoContainer = $("#AutocompleteId").data("kendoAutoComplete"); var result = $.grep(autoContainer.dataSource.data(), function (item) { item.Text == autoContainer.value(); }); } </script>@{ Html.RenderAction("Customers", "ManageDDLs", new { area = "Shared" }); }[ChildActionOnly] public ActionResult Customers() { List<ddlOptions> viewModel = new List<ddlOptions>(); viewModel = _manageDDLsAppServ.GetCustomersDDLViewModel(_currentCompanyId).ToList(); ViewBag.ControlId = "customerIdFilter"; return PartialView("_ddlOptionsAutoComplete", viewModel); }