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

Open Dropdownlist on focus.

3 Answers 181 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gurarpan
Top achievements
Rank 1
Gurarpan asked on 31 Aug 2011, 08:40 PM
Hi ,

I am using Telerik MVC dropdownlist and I want to open dropdownlist when it get focus.

I found similar property in telerik rad dropdownlist but not in mvc dropdownlist.

Or

Dropdown should changed color on getting focus.



Could you suggest some Idea.

3 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 01 Sep 2011, 09:42 AM
Hi Gurarpan,

You can do it like this:
   <%= Html.Telerik().DropDownList()
.Name("DDL1")
   .ClientEvents(events => events.OnLoad("openOnFocus"))
       .Items(item =>
       {
           item.Add().Text("Item1").Value("1").Selected(true);
           item.Add().Text("Item2").Value("2");
           item.Add().Text("Item3").Value("3");
       })
    
   %>
   <script type="text/javascript">
 
       function openOnFocus() {
           var ddl = $(this);
 
           ddl.closest(".t-widget").focus(function () {
               ddl.data("tDropDownList").open();
           });
 
       }
   </script>


Regards,
Georgi Tunev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Gurarpan
Top achievements
Rank 1
answered on 07 Sep 2011, 05:32 PM

Hi Georgi,

Thanks for your response.

Below code is working fine. But my dropdownlist is not getting open when I click on it.

I tried to combine the code like below still click event is not working.

Any Idea.

function openOnFocus() {

           var ddl = $(this);
 
           ddl.closest(".t-widget").focus(function () {
               ddl.data("tDropDownList").open();
           });
            
                ddl.closest(
".t-widget").click(function () {
               ddl.data("tDropDownList").open();
           });

 
       }
0
Georgi Tunev
Telerik team
answered on 08 Sep 2011, 02:12 PM
Hello Gurarpan,

Try calling the open() method with a timeout:

function openOnFocus() {
 
    var ddl = $(this);
 
    ddl.closest(".t-widget").focus(function () {
        window.setTimeout(function () {
            ddl.data("tDropDownList").open();
        });
    });
 
}


All the best,
Georgi Tunev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

Tags
ComboBox
Asked by
Gurarpan
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Gurarpan
Top achievements
Rank 1
Share this question
or