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

Setting default value in kendogrid from JSON data

1 Answer 86 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Lloyd
Top achievements
Rank 1
Lloyd asked on 15 Sep 2015, 04:34 PM

 Please find the below code as i want to set default value of dropdown instead of optionlable from  JSON data which is returned from controller .

Please find the below code

 

 

@(Html.Kendo().DropDownList()
              .Name("DropDownList1")
                                       
              .HtmlAttributes(new { style = "width:300px" })
              .OptionLabel("Select ...")
              .DataTextField("District_Id")
              .DataValueField("Location_ID")
            
             
                      .DataSource(source =>
           {
               source.Read(read =>
                  {
                      read.Action("GetOrders", "IDTDashboard");
                  })
                  .ServerFiltering(true);
           })
           .AutoBind(false)

 

public ActionResult GetOrders()
       {
           List<usp_IDQ_GetLicenseDistrictsVO> objresult1 = new List<usp_IDQ_GetLicenseDistrictsVO>();
           objresult1 = objConnection.usp_IDQ_GetLicenseDistricts(User.Identity.Name, true).ToList();
           return Json(objresult1, JsonRequestBehavior.AllowGet); ;
       }

1 Answer, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 17 Sep 2015, 11:40 AM
Hello Lloyd,

Probably, I am missing something, but you can set the selected value of the widget using its Value method or defining the selected index. The code should looks something like this:
@(Html.Kendo().DropDownList()
    .Name("DropDownList1")
    ....
    .Value("selected value is passed here")
)

Could you elaborate a bit more on the scenario if I missed the point?

Regards,
Georgi Krustev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DropDownList
Asked by
Lloyd
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Share this question
or