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

1

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
});
Chore answered 24/11, 2014 at 6:35 Comment(0)
S
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.

Skyjack answered 24/11, 2014 at 11:16 Comment(6)
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.Chore
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.Skyjack
ya but combo-box is editable..we can type in it...In the combo-box I think there is a placeholder...Chore
Yes. Combo-box allows place holder(exactly as you need).:)Skyjack
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....Chore
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.Skyjack

© 2022 - 2024 — McMap. All rights reserved.