javascript error

3 posts, 0 answers
  1. Andrew
    Andrew avatar
    5 posts
    Member since:
    Jan 2012

    Posted 11 Jun 2014 Link to this post

    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. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2153 posts

    Posted 11 Jun 2014 Link to this post

    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.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Andrew
    Andrew avatar
    5 posts
    Member since:
    Jan 2012

    Posted 11 Jun 2014 in reply to Dimiter Madjarov Link to this post

    Hi Dimiter,

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

    Regards
    Andrew
Back to Top