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

optionLabel as a normal option

5 Answers 561 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 1
Pierre asked on 21 Apr 2016, 09:06 AM

Hi !

I'd like to know if it's possible to display the optionLabel as the first option of the DropDownList. I need this functionality to be homogeenous with other select components.

I also would like to know if it's possible to manage the "required" attribute if I create an option by myself without using the "optionLabel".

 

Thanks for your help.

 

 

 

5 Answers, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 25 Apr 2016, 06:58 AM
Hello,

I am not sure I understand your question very well. Basically, the optionLabel gets displayed as a first option by default. Also, the "required" validation rule works as expected when the optionLabel is selected. Would you please check this example and let me know if I am missing something?

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Rick
Top achievements
Rank 2
answered on 27 May 2016, 04:15 PM

Hello,

I have a similar need. I want all the values in the datasource to be presented without an optionLabel. I set default values on the create window. optionLabel's translate to null which I do not want to allow.

Rick

0
Alexander Popov
Telerik team
answered on 30 May 2016, 07:34 AM
Hello Rick,

Can you share more details about your scenario and if possible - some code snippets? 

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Rick
Top achievements
Rank 2
answered on 31 May 2016, 07:38 PM

I see in my code below that I am specifying an optionLabel text value.

I think that I want to have a default value and show its text.

Null is not permitted as a value here, and in other similar situations.j

Thanks,

Rick

$("#IssueType").kendoDropDownList({ dataSource: window.DataSource.IssueTypeDS,
    autoBind: true,
    dataTextField: "IssueTypeName",
    dataValueField: "IssueType",
    valuePrimitive: true,
    optionLabel: localize("format", "SelectType")
});

0
Alexander Popov
Telerik team
answered on 02 Jun 2016, 10:55 AM
Hello Rick,

In case no option label is required, then I would recommend omitting the configuration option entirely: 
$("#IssueType").kendoDropDownList({ dataSource: window.DataSource.IssueTypeDS,
    autoBind: true,
    dataTextField: "IssueTypeName",
    dataValueField: "IssueType",
    valuePrimitive: true
});


Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
DropDownList
Asked by
Pierre
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Rick
Top achievements
Rank 2
Share this question
or