This is a migrated thread and some comments may be shown as answers.

Setting optionLabel after initiation

5 Answers 883 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Web
Top achievements
Rank 1
Web asked on 01 Jun 2012, 10:49 AM
Is there a way to set the optionLabel after the initiation, because I want it to be dependent on the value of the data.
If there is no data I want my users to know, that there are no options anymore.

Otherwise I just do a jquery.html() on that element. But it would be nice if I can set it with the API

5 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 05 Jun 2012, 06:51 AM
Hi,

 
Generally speaking, you can add the optionLabel after init. You just need to recreate items of the drop-down list. Other option is to use the text method of the DropDownList to set the text of the span element. Check this jsFiddle demo, which shows the both approaches.

As a side note, I will suggest you open support tickets for your incedents. Thus our support team can handle the problems faster. We also do not guarantee answers in the forum threads.

Kind regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 11 May 2018, 07:43 AM

Hi Georgi,

I have a requirement to have an optional label on a dropdownlist that has the datasource changed dynamic. I have updated your demo with the latest version of kendo and it does not work. 

http://jsfiddle.net/pvwqU/490/

What do I need to do to make it work?

0
Ivan Danchev
Telerik team
answered on 16 May 2018, 06:47 AM
Hi Dan,

Instead of setting the optionLabel like this:
ddl.options.optionLabel = "Select item";

you can use the setOptions API method to set it:
ddl.setOptions({ optionLabel: "Select item" });

Updated example.

Regards,
Ivan Danchev
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
answered on 22 May 2018, 07:21 AM

Hi Ivan,

Thank you, it works with your solution.

0
Sivaramakrishna Reddy
Top achievements
Rank 1
Veteran
answered on 12 May 2020, 07:57 AM
Thank you. It is working for me.
Tags
DropDownList
Asked by
Web
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Dan
Top achievements
Rank 1
Iron
Iron
Veteran
Ivan Danchev
Telerik team
Sivaramakrishna Reddy
Top achievements
Rank 1
Veteran
Share this question
or