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

Ajax Binding return 'undefined' results in list

3 Answers 287 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 06 Dec 2012, 07:33 PM
Hi,

I'm not able to get Ajax binding to work with my combobox.  I went the Kendo Ajax binding example to the letter.  The combox box returns 'undefined' in the results.  I verified that the controller method is called.

Controller:
public JsonResult GetContainers()
        {
            List<Container> containers = new List<Container>();
            containers.Add(new Container() { ContainerId = 1, ContainerName = "Container1" });
            containers.Add(new Container() { ContainerId = 2, ContainerName = "Container2" });
  
            return Json(containers);
        }
View:
    @(Html.Kendo().ComboBox()
        .Name("TestContainerName")
        .DataTextField("ContainerName")
        .DataValueField("ContainerId")
        .Filter(FilterType.Contains)
            .DataSource(dataSource =>
            {
                dataSource.Read(read =>
                    {
                        read.Action("GetContainers", "Common");
                    });
            })
        .SelectedIndex(0)
)

3 Answers, 1 is accepted

Sort by
0
Accepted
Georgi Krustev
Telerik team
answered on 07 Dec 2012, 10:20 AM
Hello Jeff,

 
The only thing I can spot in the code snippet is the missing second parameter in the Json method. By default the DataSource makes GET requests to the server and you will need to allow these requests:

return Json(containers, JsonRequestBehavior.AllowGet);
If the problem still persist I will need a repro test project.

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!
0
Karl
Top achievements
Rank 1
answered on 26 Feb 2014, 05:42 PM
I had the same problem.  If you look at the json being returned you'll see it returns Text and Value not your property names.  I can't figure out why though.
0
Mark
Top achievements
Rank 2
answered on 09 Jun 2016, 03:20 PM
This post and Karl's answer helped me a LOT today.  Thanks!
Tags
ComboBox
Asked by
Jeff
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Karl
Top achievements
Rank 1
Mark
Top achievements
Rank 2
Share this question
or