AJAX AutoComplete not displaying the items

4 posts, 0 answers
  1. Dave
    Dave avatar
    35 posts
    Member since:
    Oct 2012

    Posted 05 Nov 2012 Link to this post

    Hi. I just want to display a list of values that are retrieved serverside using AJAX.  It calls the AJAX method successfully, but does not display the returned values.

    Markup:

          @(Html.Kendo().AutoComplete()
    .Name("EditNameAutoComplete")
    .DataSource(source =>
                source.Read(read => read.Action("GetUsers", "Administration"))
                    .ServerFiltering(true)))

    Method:

    public JsonResult GetUsers()
    {
        string input = Request.Params["filter[filters][0][value]"];
        var adValues = //Get names from Active Directory that start with our input
        var users = adValues.Select(user => user.CommonName).ToList();
        users.Sort();
        return Json(users);
    }

    Should be simple enough, and it's calling the Ajax method, but not displaying anything afterward. It just acts like a normal textbox. I'm definitely returning strings. What am I doing wrong?
  2. Dave
    Dave avatar
    35 posts
    Member since:
    Oct 2012

    Posted 05 Nov 2012 Link to this post

    Disregard, I figured it out. I should have been specifying AllowGet for the JSON, like so:

    return Json(users, JsonRequestBehavior.AllowGet);

    Woohoo!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Dave
    Dave avatar
    35 posts
    Member since:
    Oct 2012

    Posted 05 Nov 2012 Link to this post

    New question - is there a way to set up Kendo AutoComplete to perform a POST instead of a GET, using the MVC extensions?
    Thanks.
  5. Dave
    Dave avatar
    35 posts
    Member since:
    Oct 2012

    Posted 16 Nov 2012 Link to this post

    Aha, found it.

    @(Html.Kendo().AutoCompleteFor(m => m.NewIssue.Responsible)
          .MinLength(3)
          .HtmlAttributes(new { @class="autocomplete" })
            
          .DataSource(ds => ds.Read(r => r.Action("GetUserNames", "Ajax").Type(HttpVerbs.Post))
                              .ServerFiltering(true)))
Back to Top
UI for ASP.NET MVC is VS 2017 Ready