Setting default value of a dropDownList

11,441

1) For dropdown list use select

var dropdownlist = $("#dropdownlist").data("kendoDropDownList");
dropdownlist.select(1);

(There are different options how to select specific item.)

Grid edit event example with your drop down list,

 edit: function(e) {
    if (e.model.isNew()) {
        var ddl = e.container.find("input[name=id]").data("kendoDropDownList");
        ddl.select(1);
    }
  } 

2) This is how to use custom editor in your grid, just in case your dropdown is not populated yet.

3) You could also use OptionLabel

Share:
11,441
user2012783
Author by

user2012783

Updated on June 13, 2022

Comments

  • user2012783
    user2012783 about 2 years

    ive been using this to set a default text form input on a kendo grid which works fine.

     e.container.find("input[name=policy]").val(lender_policy).change();
    

    however if i try and set a default value of a dropDownListlike below, it sets the value of the dropdownlist, but it insert blank data to the grid and DB. im guessing its because change() may need to be called like the text input but am not sure how that can be done.

     e.container.find("input[name=lender]").data("kendoDropDownList").value(lender);
    

    any help on this would be great.