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
210
Properly clearing a selection (CSOM)
posted

Hi all,

 

we're using the WebDropDown v9.2 and i'd like to know if anyone knows of a way to properly clear the selection. I'd need it to do the following in the latest Firefox release (3.5):

  • Clear the visible text
  • Clear the current value
  • Remove the selection in the list
  • Fire its Selectionchanging, Selectionchanged, Valuechanging, Valuechanged events

 

Thanks in advance,

Dominik

Parents
  • 24671
    Suggested Answer
    posted

    Hi Dominik,

    Sorry for the delay. About your question, you can achieve that using the following code:

    dropDown.set_currentValue("", true);

    dropDown.get_selectedItem().unselect();

    In case you are using multiple selection, you can still clear it on the client-side by iterating through the items and calling unselect on each one. 

    Events won't be fired in the above case, because client-side events for the controls are only fired when there is end-user interaction. If API for the CSOM is directly used, it is assumed that the Developer knows what's going on, so the events don't have to be raised. I.e. you can call your event handler there directly.

    Hope it helps. Please let me know if this solves your question, and whether i can help you with anything else.

    Thanks,

    Angel 

Reply Children
No Data