JQueryUIAutocomplete example?

Sep 23, 2013 at 6:51 PM
Edited Sep 23, 2013 at 6:53 PM
Is there an example somewhere using JQueryUIAutocomplete? I've got a property on my model:
[Required]
[Range(0, Int32.MaxValue)]
[JqGridColumnEditable(true, "DistIdAutoComplete", "Account", EditType = JqGridColumnEditTypes.JQueryUIAutocomplete)]
public int DistId { get; set; }

That is successfully returning data from the "Account" controller, and the dropdown is painting, but the actual returned values are not being displayed (almost like they are hidden), and when I click on one, the textbox is wiped out.

Image

jquery 1.10.2
jquery.ui.combined 1.10.3
jquery.jqgrid 4.4.4
lib.web.mvc 6.3.1
Sep 23, 2013 at 8:40 PM
Turns out the problem was in the Account controller response- AutoComplete is looking for a key/value pair in the response, and I was only returning a single value:
return Json(business.IDAutoCompleteSearch(term).Select(a => a.DistId).ToArray(), JsonRequestBehavior.AllowGet);
Once I started returning a key/value pair, it painted correctly:
return Json(business.IDAutoCompleteSearch(term).Select(d => new {key = d.DistId, value = d.DistId}).ToArray(), JsonRequestBehavior.AllowGet);
Coordinator
Sep 23, 2013 at 10:12 PM
Well this is odd to be honest. The sample project (jqGrid in ASP.NET MVC - Strongly typed helper) is using JQueryUIAutocomplete and a single value is enough to make it work:
public ActionResult ProductsNames(string term)
{
    return Json(_productsRepository.Find(String.Format("Name.StartsWith(\"{0}\")", term)).Select(p => p.Name).ToArray(), JsonRequestBehavior.AllowGet);
}
So the issue should be something else (maybe to fact of returning ints instead of strings or something).