Skip to content

Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / Moving through the dropdown with the arrow keys always starts on the first element

Moving through the dropdown with the arrow keys always starts on the first element

New Discussion
Carlos
Carlos asked on Dec 18, 2015 3:03 PM

Hi,

I’ve noticed that if you have a dropdown with a pre-selected value, like this for example:

<ig:WebDropDown ID=”ddl1″
runat=”server”
DropDownContainerWidth=”230px”
DropDownContainerHeight=”0″
Width=”230″
DisplayMode=”DropDown”
EnableRenderingAnchors=”False”
KeepFocusOnSelection=”True”
EnableAutoCompleteFirstMatch=”True”
EnableDropDownAsChild=”True”
AutoSelectOnMatch=”True”
EnableAutoFiltering=”Client”
EnableCustomValues=”True”
OnSelectionChanged=”ddl1_SelectedIndexChanged”>
<AutoPostBackFlags SelectionChanged=”On” ValueChanged=”Off”></AutoPostBackFlags>
<Items>
<ig:DropDownItem Text=”text1″ Value=”text1″ />
<ig:DropDownItem Text=”text2″ Value=”text2″ Selected=”True”/>
<ig:DropDownItem Text=”text3″ Value=”text3″/>
</Items>
</ig:WebDropDown>

 

If you move through the items with the arrow keys you always start in the first element of the list no matter what is selected in the dropdown. For example, if the second value is selected and you press the down arrow key, I think it should move down to the third, but it goes to the first instead.

Is this the expected behaviour? Is there an easy way around it?

Sign In to post a reply

Replies

  • 0
    Ivaylo Ganchev
    Ivaylo Ganchev answered on Dec 17, 2015 2:24 PM

    Hello,
    you are experiencing the default behavior. When using the keyboard to select the next item, the selection will always start from the first item in the available list of items. I will further investigate the possibilities to work around this and come back to you with more details.

    • 0
      Carlos
      Carlos answered on Dec 17, 2015 2:44 PM

      Hi,

      I have found a more or less decent implementation for it. Here's what I have so far.

      function initializeWebDropDowns() {

      if (e.keyCode === 38 || e.keyCode === 40) {
      var instance = $IG.WebDropDown.find($(e.target).parents(".igdd_ClaymationControl")[0].id);
      var currentItemIndex = instance.get_selectedItemIndex();
      var numberOfItems = instance.get_items().getLength();
      var newPosition;
      if (e.keyCode === 38) {
      newPosition = currentItemIndex === 0 ? 0 : currentItemIndex – 1;
      instance.selectItemByIndex(newPosition, true, true);
      return false;
      }
      if (e.keyCode === 40) {
      newPosition = currentItemIndex === numberOfItems – 1 ? numberOfItems – 1 : currentItemIndex + 1;
      instance.selectItemByIndex(newPosition, true, true);
      return false;
      }
      }
      return true;
      });
      }

      However, this way the SelectionChanged and SelectionChanging events are not triggered anymore.

      Is there a way to trigger them programatically after changing the selected item?

      I also think you should review some of these "default behaviours". This is not really what most people would expect as default from a dropdown and it shouldn't be so tricky to achieve for us developers.

      • 0
        Ivaylo Ganchev
        Ivaylo Ganchev answered on Dec 18, 2015 3:03 PM

        Hello,

        n order to visually see the change when you select an item and the corresponding css be applied to this item, instead of just internally marking it as selected, you could achieve this using the select() method on the desired item. Please notice, currently it is best to use the items index to manipulate them so you could consider using something like the approach described in the following threads.

         

        http://ko.infragistics.com/community/forums/t/51039.aspx
        http://ko.infragistics.com/community/forums/t/30177.aspx

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Carlos
Favorites
0
Replies
3
Created On
Dec 18, 2015
Last Post
10 years, 2 months ago

Suggested Discussions

Created by

Created on

Dec 18, 2015 3:03 PM

Last activity on

Feb 23, 2026 9:00 AM