Combox Server binding issue

2 posts, 0 answers
  1. Sanjeev
    Sanjeev avatar
    1 posts
    Member since:
    Sep 2014

    Posted 26 Sep 2014 Link to this post

    My Kendo Comboxbox server binding is not working

    This is my View
     @(Html.Kendo().ComboBox()
                  .Name("cbxState")
                  .HtmlAttributes(new { style = "width:150px" })
                  .Text("Select State")
         
                  .DataTextField("Code")
                  .DataValueField("Code")
                   .Filter(FilterType.Contains)
                  .DataSource(source =>
                  {
                      source.Read(read =>
                      {
                          read.Action("cbx_read", "Home");
                      })
                      .ServerFiltering(true);
                  })
                  )


    This is my Controller       

    public ActionResult cbx_read([DataSourceRequest]DataSourceRequest request)
             {
                 using (var northwind = new Connection())
                 {
                     IQueryable<LostDayDetail> Customers = northwind.LostDayDetail;
                     DataSourceResult result = Customers.ToDataSourceResult(request, Customer => new CustomerDetail
                     {
                         Code = Customer.Code,
                         Name = Customer.Name,
                         Days = Customer.Days
                     });
                     return Json(result);
                 }
            }

    When I click on Combobox, it calls cbx_read function and it gets all 12 rows of data from database table. but when contol comes back to view, the combobox is blank.
    Please help me




  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 29 Sep 2014 Link to this post

    Hello Sanjeev,

    In general, ComboBox widget supports seamless binding to an array of objects/primitive values. The DataSourceResult is not supported out of the box as it is designed to work with widgets with CRUD abilities (Grid and etc). Check this help topic for more information.

    Regards,
    Georgi Krustev
    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
Back to Top