function
Zip_AutoComplete(e) {
e.data = $.extend({}, e.data, { state: $(
"#State").val(), city: $("#City").val() });
}
@(Html.Telerik().AutoComplete()
.Name(
"Zip")
.Encode(
false)
.Filterable(f => f.FilterMode(
AutoCompleteFilterMode.Contains))
.HighlightFirstMatch(
true)
.ClientEvents(events => events.OnDataBinding(
"Zip_AutoComplete"))
.DataBinding(a => a.Ajax().Select(
"ZipList", "Rat"))
.AutoFill(
true)
.HtmlAttributes(
new { style = string.Format("width:{0}px", 90) })
)
[
Authorize]
public ActionResult ZipList(string text, string state, string city) {
var zips = _entities.Locations.Where(l => l.State == state
&& (city.Length == 0 || l.City.StartsWith(city)))
.Select(l => l.ZipCode).Distinct()
.OrderBy(o => o)
.ToList();
return new JsonResult { Data = zips };
}