Combobox using server filtering does not work using post

3 posts, 0 answers
  1. Tom
    Tom avatar
    1 posts
    Member since:
    Dec 2005

    Posted 17 Dec 2012 Link to this post

    Using version 2012.3.1114.

    This work using Visual Studio Development Server but does not show the drop down using IIS Express or IIS 7 on Windows Server 2008 R2
    Code in view:

    @(Html.Kendo().ComboBoxFor(m => m.ForPost)
          .Filter(FilterType.StartsWith)
          .DataTextField("label")
          .DataValueField("value")
          .MinLength(1)
          .DataSource(source => {
              source.ServerFiltering();
              source.Read(read => {
                  read.Action("AjaxPost", "Home"); //Set the Action and Controller name
                  read.Type(HttpVerbs.Post);
              });
          }))
    Code in Controller:

     

    [HttpPost]
    public ActionResult AjaxPost(string text) {
        if (string.IsNullOrWhiteSpace(text)) return Json(null);
        var x = Data.Where(d => d.StartsWith(text, StringComparison.InvariantCultureIgnoreCase))
            .Select(d => new { label = d, value = d }).ToList();
        return Json(x);
    }

    IE 9 in Javascript debug it shows this error "Microsoft JScript runtime error: Unable to get value of the property 'Errors': object is null or undefined" and pints the this dynamic code.

    function anonymous(d) {
    return d.Errors
    }

    Using get works fine but our security people insist we use post for ajax.

    Thanks,

    Tom Wilkinson

     

  2. Tom
    Tom avatar
    1 posts
    Member since:
    Dec 2005

    Posted 18 Dec 2012 Link to this post

    Found a solutions.  Do NOT return Json(null);
    Return an empty list.
    This is odd because a null works fine with an AutoComplete.

    Hope this helps someone else.

    Tom
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 19 Dec 2012 Link to this post

    Hello Tom,

     
    I tried to replicate the issue, but to no avail. The ComboBox works as expected even when the return result is null. Check this screencast for more information.

    Regards,
    Georgi Krustev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top