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

Up and Down Arrow Selecting Non Visible Items

2 Answers 87 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Jon Shipman
Top achievements
Rank 1
Jon Shipman asked on 27 Oct 2010, 06:15 PM
I'm working on a project where I set the visible property on certain listboxitems to false using set_visible(false).  It works great, but if the user uses the up and down arrow to select a listboxitem, the control selects the "hidden" listboxitem which makes it appear that the up/down arrow selection is malfunctioning.

Is there a way to override this?

I propose that the up/down arrow functionality be changed to only select the next visible listboxitem.

Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Genady Sergeev
Telerik team
answered on 02 Nov 2010, 11:51 AM
Hello Jon Shipman,

Thank you for reporting this issue to us. I've logged it into our bug tracking system and we will fix it as soon as possible. Meanwhile you can use the following workaround:

<script type="text/javascript">
      
     var originalKeyDown = Telerik.Web.UI.RadListBox.prototype._onKeyDown;
     // true -> downwards; false -> upwards
     var modifier = 0;
 
     Telerik.Web.UI.RadListBox.prototype._onKeyDown = function (e) {
         if (e.keyCode == Sys.UI.Key.down)
             modifier = 1;
         else if(e.keyCode = Sys.UI.Key.up)
             modifier = -1;
         else
             modifier = 0;
          
         originalKeyDown.apply(this, [e]);
     }
 
     function changed(sender, args) {
         if (modifier != 0) {
             var itemsCount = sender.get_items().get_count();
             var currentIndex = args.get_item().get_index();
             var item = args.get_item();
 
             if (!item.get_visible()) {
                 var itemToSelect = sender.getItem(currentIndex + modifier);
                 if (itemToSelect) {
                     itemToSelect.set_selected(true);
                     sender._activateItem(itemToSelect);
                 }
 
             }
         }
     }
 </script>

I've also updated your telerik points for the report.

All the best,
Genady Sergeev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Jon Shipman
Top achievements
Rank 1
answered on 03 Nov 2010, 08:38 PM
Great!  Thank you very much!

I also just recently noticed that if SelectionMode="Multiple", shift + select will select all the hidden listboxitems as well.

I'm going to be using SelectionMode="Single" for my current project, so I don't need a work-around for this.

Thanks again.  Telerik has amazing customer support!
Tags
ListBox
Asked by
Jon Shipman
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Jon Shipman
Top achievements
Rank 1
Share this question
or