Sveta Antrapovich Sveta Antrapovich - 1 year ago 187
ASP.NET (C#) Question

Kendo autocomplete undefined value

I'm trying to make an autocomplete ( core)

Razor view:

.Placeholder("Type user name...")
.Events(e =>
.DataSource(source =>
source.Read(read =>
read.Action("GetUsers", "User").Data("onAdditionalData");
.HtmlAttributes(new { style = "width:30%" })
.Template("<span class=\"k-state-default\">\\#=users.Email\\#</span>"))

Server side:

public dynamic GetUsers(string term)
return ctx.Users.Where(x => x.Email.ToUpper().Contains(term.ToUpper()))
.Select(res => new { id = res.Id.ToString(), name = res.Email }).ToList();

In my view I always get right number of value, but it is always "undefined". Where I`m wrong?

Answer Source

You are renaming "Email" to "name" in your server-side action; So you should use

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download