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

Combox Server binding issue

1 Answer 90 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Sanjeev
Top achievements
Rank 1
Sanjeev asked on 26 Sep 2014, 07:08 AM
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




1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 29 Sep 2014, 10:14 AM
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.

 
Tags
ComboBox
Asked by
Sanjeev
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or