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

[Solved] AutoComplete w .Net MVC - not able to handle JsonResult object

0 Answers 14 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Sean
Top achievements
Rank 1
Sean asked on 23 May 2013, 05:46 PM
EDIT: PREAMBLE
This system is using Telerik 2012.1.214, which i believe is bundled with nopCommerce 2.5 
For various reasons we cannot upgrade our frameworks at this time.


I am trying to use an AutoComplete method on some fields within a Grd. It "works", meaning the call to the Ajax function happens, the Controller handles, bundles and serializes the result and sends it back

My browser Inspector tells me, however, "Uncaught TypeError: Object [object Array] has no method 'toLowerCase'"
The Response panel shows me I am receiving: {"data":["Grey He","Grey Hea","Grey Heat","Grey Heath","Grey Heathe","Grey Heather","Grey Heather","Grey Heather/Moose"],"total":0}
I suspect that it has something to do with 'data' being an array inside an object, rather than just an array, but I could be wrong. What might I be missing in the following pieces.....


the Telerik control looks like this:

(Html.Telerik().AutoComplete()
                .Name(name1)           
                .DataBinding(dataBinding => dataBinding.Ajax()
                    .Select("_AutoCompleteSpecAttrList", "Product", new { specAttrtId = attr.SpecificationAttributeId}))
                .AutoFill(true)
                .Filterable(filtering => { filtering.FilterMode(AutoCompleteFilterMode.StartsWith); })
            );



the Controller Action looks like this:

[GridAction(EnableCustomBinding = true)]
       public JsonResult _AutoCompleteSpecAttrList(GridCommand command, int specAttrtId, string text)
       {
 
           var attributeList = new List<string>();
           var attributespecificationsoptopns = _specificationAttributeService.GetSpecificationAttributeOptionsBySpecAttrIdandStringOrderByName(specAttrtId, text);
 
           foreach (var c in attributespecificationsoptopns)
           {
               attributeList.Add(c.Name.Trim());
           }
 
           JsonResult newList = Json(attributeList.ToList());
           return newList;
       }
Tags
ComboBox
Asked by
Sean
Top achievements
Rank 1
Share this question
or