how to add css class to already created dropdpownlist?

1 Answer 4904 Views
DropDownList
Sergi
Top achievements
Rank 1
Sergi asked on 20 Jun 2013, 02:08 PM
I'm trying on document.ready to call:
$("#ID_Comercial").addClass('mandatory');
But it doesn't works, the class gets added to an input shown below, but not to the actual dropdownlist, so it's not displaying the new styles :
<input id="ID_Comercial" class="mandatory" type="text" style="width: 200px; display: none;" name="ID_Comercial" data-role="dropdownlist">
How can I add a css class or remove it from an existing dropdownlist or any other kendo widget?

Thanks in advance.

1 Answer, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 21 Jun 2013, 08:17 AM
Hello Sergi,

You have two options:

1. Add the custom class before the DropDownList is initialized. In this case it will be copied to the widget wrapper automatically.

2. Add the custom class to the wrapper directly:

$("#ID_Comercial").closest('.k-dropdown').addClass('mandatory');


UPDATED: The correct class is k-dropdown
 
 
Regards,
Dimo
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Sergi
Top achievements
Rank 1
commented on 25 Jun 2013, 07:10 AM

Thanks, I can't do it before the dropdownlist is initialized because the classes get added and removed dynamically depending on what the user has selected on the UI.
$("#ID_Comercial").closest('.k-dropdownlist').addClass('mandatory');
The code you provided is not working, but I found the error, it should be k-dropdown instead of k-dropdownlist:
$("#ID_Comercial").closest('.k-dropdown').addClass('mandatory');
Thanks.
Tags
DropDownList
Asked by
Sergi
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Share this question
or