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
444
How can I programatically (CSOM) select an Item in the WebDropDown?
posted

Hi Guys,

I am trying to select an item in the WebDropDown without clicking it.  I see the methods to set an active item and also select an item by index. How can I use them?

I have this 

 

var tmp = $find("LetterDropDown1");

 

var items = tmp.get_items();

 

 

var itemToSelect;

The "items" doesn't seem to be an Array. What I'm trying to do here is say I have a value ("99"), how do I find the item in the drop down who's value is "99" and then make that be the selected item? I want it to be like the user opened the dropdown and made a selection. How in the world can I do this? I fought tooth and nail to not use Infragisitcs controls in this project as there is so very little support and documentation, but nonetheless I was forced into using the WebDropDown here. Please proove me wrong and demonstrate good customer service and tech support and show a very simple example of how to accomplish this. Prefereably this week as the normal turn around seems to be weeks. Can you help me?

Thanks,

Kettenbach

Parents
No Data
Reply
  • 24671
    Suggested Answer
    posted

    Hi Kettenbach,

    The API doesn't include a function to get an item by value on the client-side, but you can accomplish this in the following way (get_items() returns an object of type $IG.DropDownItemCollection):

    var items = tmp.get_items();

    var myItem = null;

    for(i = 0; i < items.getLength(); i++)

    {

       var item = items.getItem(i);

    if (item.get_value() == '99')

      {

           myItem = item;

            break;

       }

    }

     

    if (myItem)

    {

        tmp.selectItem(myItem);

    }

     

    or just tmp.selectItemByIndex(<some item index>);

    or myItem.select(); // this will not activate the item and will not change the input value to match the item's text.

    I hope you are also using the latest Service Release, to avoid any ambiguity about issues that are already fixed.

    Please let me know if you need any additional help. Thank you,

    Angel 

     

Children