Articles in this section
Category / Section

How to set focus to the filterSearch textbox dynamically?

2 mins read

Description:

Set focus to the filter search box of DropDownList dynamically.

Solution:

Set focus to the filter search input box of DropDownList dynamically by executing the focus () method on search box in the _OnPopupHideShow method of DropDownList.

Refer to the following code snippet:

Javascript:

<input type="text" id="skillsets" />
 
<script type="text/javascript">
        var target;
        $(function () {
            var skillset = [
                { skill: "ASP.NET" }, { skill: "ActionScript" }, { skill: "Basic" },
                { skill: "C++" }, { skill: "C#" }, { skill: "dBase" }, { skill: "Delphi" },
                { skill: "ESPOL" }, { skill: "F#" }, { skill: "FoxPro" }, { skill: "Java" },
                { skill: "J#" }, { skill: "Lisp" }, { skill: "Logo" }, { skill: "PHP" }
            ];
            $('#skillsets').ejDropDownList({
                dataSource: skillset,
                fields: { text: "skill" },
                enableFilterSearch:true,
                showCheckbox: true,
            });
            target = $('#skillsets').data("ejDropDownList");
             var srcFunction = target._OnPopupHideShow; 
             target._OnPopupHideShow = function (e) { 
                srcFunction.call(this, e); 
               $(target.inputSearch).focus();             
            }
        });
      
          </script>

 

DropDownlist

 

 

N>  By default, filter search input box will be focused on popup in 15.2.0.40 and the above versions. This workaround is applicable for older versions that is before 15.2.

 

 

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied