This is a migrated thread and some comments may be shown as answers.

Combobox using server filtering does not work using post

2 Answers 209 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Tom
Top achievements
Rank 1
Tom asked on 17 Dec 2012, 04:59 PM

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 Answers, 1 is accepted

Sort by
0
Tom
Top achievements
Rank 1
answered on 18 Dec 2012, 02:56 PM
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
0
Georgi Krustev
Telerik team
answered on 19 Dec 2012, 09:59 AM
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!
Tags
ComboBox
Asked by
Tom
Top achievements
Rank 1
Answers by
Tom
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or