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

javascript error

2 Answers 112 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 11 Jun 2014, 10:34 AM
Hi Guys,

I am using the Combobox and it is giving me a javascript error. I have made sure JQuery is only included once and other Kendo controls are working.

Razor Code
@(Html.Kendo().ComboBox()
                            .Name("Projects")
                            .DataTextField("ProjectName")
                            .DataValueField("ProjectID")
                            .HtmlAttributes(new { style = "width:200px" })
                            .Filter("contains")
                            .AutoBind(false)
                            .MinLength(3)
                            .DataSource(source =>
                            {
                                source.Read(read => { read.Action("GetProject", "VMS"); }).ServerFiltering(true);
                            })) 

Controller Code
public JsonResult GetProject([DataSourceRequest] DataSourceRequest request)
        {
            var model = _db.Project.ToList();
            var result = model.ToDataSourceResult(request, r => new
            {
                ProjectID = r.ID,
                ProjectName = r.Name,
            });
            return Json(result, JsonRequestBehavior.AllowGet);
        }

JSON from fiddler
{"Data":[{"ProjectID":1,"ProjectName":"Project 1"},{"ProjectID":2,"ProjectName":"Project 2"},{"ProjectID":3,"ProjectName":"Project 3"}],"Total":3,"AggregateResults":null,"Errors":null}

Chrome error
Uncaught TypeError: undefined is not a function kendo.all.min.js:11
ct.extend.success kendo.all.min.js:11
b.isFunction.i jquery-1.9.1.js:7223
n.success kendo.all.min.js:11
c jquery-1.9.1.js:7341
p.fireWith jquery-1.9.1.js:7403
k jquery-1.9.1.js:9597
r

Thanks
Andrew





2 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 11 Jun 2014, 11:42 AM
Hi Andrew,


The ComboBox widget does not require calling the ToDataSourceResult method when returning the data. It expects a regular JSON result as demonstrated on the following documentation page.

I hope this information helps.

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Andrew
Top achievements
Rank 1
answered on 11 Jun 2014, 09:35 PM
Hi Dimiter,

Thanks, all working now. I should of looked more clearly at the documentation.

Regards
Andrew
Tags
ComboBox
Asked by
Andrew
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or