Skip to content

Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / Is it possible to hide an individual item in the dropdown list client side?

Is it possible to hide an individual item in the dropdown list client side?

New Discussion
Ian
Ian asked on Sep 28, 2010 6:50 AM

I have two WebDropDown controls that are being initialized with a dummy item similar to “Please select X from the list”.  I don’t want those dummy entries to show up in the list when they open it.  I was hoping there would be some sort of NullText property for the CurrentValue like the ones in the TextEditor controls, but I haven’t found anything like that.  Any help would be greatly appreciated!

 

Thanks, Ian.

 

Sign In to post a reply

Replies

  • 0
    Ian
    Ian answered on Sep 27, 2010 6:59 PM

    After a lot of searching I found some posts that pointed me in the right direction.  Here is how you remove an item from the dropdown.  In my case it's the first item in the list.  After you remove the item the DropDownOpening event fires again, so you need to use some sort of criteria to make sure you do't remove all of the items from the list.

     

    function ctl00_ddlReason_DropDownOpening(sender, eventArgs)
    {
    var items = sender.get_items();
    var item = sender.get_items().getItem(0);
    var value = item.get_text();
    if (value == 'Please select the reason for the down time.') {
    items.remove(item);
    }
    }

    • 0
      Alexander Todorov
      Alexander Todorov answered on Sep 28, 2010 6:50 AM

      you can just hide the item visually by setting it's style attributes display to 'none' and visibility to 'hidden'

      var item = sender.get_items().getItem(0);

      item._element.style.display='none';

      hope it helps,

      Angel

       

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Ian
Favorites
0
Replies
2
Created On
Sep 28, 2010
Last Post
15 years, 5 months ago

Suggested Discussions

Created by

Ian

Created on

Sep 28, 2010 6:50 AM

Last activity on

Feb 23, 2026 6:05 AM