Search code examples
angularjshtmlkendo-uikendo-dropdown

Kendo Dropdownlist Placeholder


I am using a kendo dropdownlist and I need a placeholder for the dropdownlist which shouldn't appear in the list when I select the dropdown. I tried using optionLabel but this value shows up in the list.

 var $dropdownElement;

    $dropdownElement = $("<input />");

    $dropdownElement.appendTo($dropdownContainer);
    $dropdownElement.kendoDropDownList({
            dataTextField: "text",
            dataValueField: "value",
            dataSource: dropdown.items,
            optionLabel: "select your option", //shows as option in dropdown
            popup: {
                appendTo: $dropdownContainer
            }
    });

I will need a solution where I can add a placeholder and that value shouldn't be shown as an option in the dropdownlist.


Solution

  • You can always find the first element in the dropwdownn list and hide it to make it look less chatty

    $dropdownElement.getKendoDropDownList().list.find("li.k-item").first().hide();
    

    Plunker Dropdownlist (and combobox) example