4

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.

Shashi
  • 1,112
  • 2
  • 17
  • 32
  • I have something similar with a combo box. Not sure how it would work with a dropdownlist that is databound: $dropdownElement.data("kendoComboBox").input.attr("placeholder","select option"); – Steve Greene Oct 22 '15 at 18:53
  • It is not the same. This is not supported out of the box. Try using the ddl events to hide the optionlabel. – Vladimir Iliev Oct 22 '15 at 19:47

1 Answers1

1

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

JFM
  • 753
  • 12
  • 16