5

I am not getting placeholder in kendo dropdownlist. Can any one suggest me for solution

HTML

<input id="inp1" type="text"/>

JavaScript

var data1 = [ //this part is related to the above html tag
    {text: "org1", value: "1", color: "#a8a9aa", selected:true },
    {text: "org2", value: "2", color: "#000", selected: false },
    {text: "org3", value: "3", color: "#000", selected: false },
    {text: "org4", value: "4", color: "#000", selected: false },
    {text: "org5", value: "5", color: "#000", selected: false }
];
$("#inp1").kendoDropDownList({      
    dataTextField : "text",
    dataValueField: "value",
    dataSource    : data1,
    placeholder:"select your option",
    select        : onSelect,
    value         :1
});
OnaBai
  • 40,767
  • 6
  • 96
  • 125

1 Answers1

10

There is no "placeholder" property of kendo drop-down widget. Instead you can do that by placing an "optionLabel" property.i.e.

 var data1 = [ //this part is related to the above html tag
                 {text: "org1", value: "1", color: "#a8a9aa", selected:true },
                 {text: "org2", value: "2", color: "#000", selected: false },
                 {text: "org3", value: "3", color: "#000", selected: false },
                 {text: "org4", value: "4", color: "#000", selected: false },
                 {text: "org5", value: "5", color: "#000", selected: false }
            ];

   $("#inp1").kendoDropDownList({      
                  dataTextField : "text",
                  dataValueField: "value",
                  dataSource    : data1 ,
                  optionLabel   : "select your option",
                  select        : onSelect
           });

Make sure that "onSelect" function is defined in javascript. For reference check here.

Satya Ranjan Sahoo
  • 1,086
  • 7
  • 24
  • 1
    But when I put this optionLable in my code this optionlable value is coming in the dropdown list.I dont want to see this optionLable text(i.e "select your option")in dropdown list.I just want to hide it in my dropdown list. – Gopi Krishnam Raju Nov 24 '14 at 12:22
  • I fear that it is not possible with this version of kendo UI. If you can extend the API it may be possible. Else use combo-box instead. – Satya Ranjan Sahoo Nov 24 '14 at 12:31
  • ya but combo-box is editable..we can type in it...In the combo-box I think there is a placeholder... – Gopi Krishnam Raju Nov 24 '14 at 12:40
  • Yes. Combo-box allows place holder(exactly as you need).:) – Satya Ranjan Sahoo Nov 24 '14 at 12:42
  • Ya but in combo-box we can type the text or we can select the text from dropdown list...But I should not need this typing the text I should select only from the dropdwon list.... – Gopi Krishnam Raju Nov 24 '14 at 12:46
  • OK. But logically place holder is used where we can type something. Thats why they have not provided placeholder for dropdownlist. So at the end its your choice what you like use. – Satya Ranjan Sahoo Nov 24 '14 at 12:48