Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
240
Is it possible to hide an individual item in the dropdown list client side?
posted

  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.

 

Parents
  • 240
    Suggested Answer
    posted

    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);
    }
    }

Reply Children
No Data