Hi.
I am using a webdropdown that has around 100 items in it. By default, on page-load, I want to select the first item in the list.
I am using
$find("webdropdown1").set_selectedItemIndex(0);
in client-side javascript. It is selecting the first item correctly. But when I open the dropdown, the first items does not show selection. The currently selected item should be highlighted in the dropdownlist. How to accomplish this?
For your Information, I have also tried :
$find("webdropdown1").set_selectedItemIndex(0, true);
but did not work.
Hello,Please take a look at the attached sample. It shows how to achieve your goals. You have to get an item and select/unselect it directly. Setting the index will not resolve the issue. Same would happen if you want to change the active item. Then you have to say item.activate/inactivate.Please let me know if the sample works for you.
Hi,
Thanks for your reply. While working on this, I got another problem. Actually, I am loadiing the items into a webdropdown using
the below code:
webdropdown1.loadItems(webdropdown2_value,false);
alert("value:" + webdropdown1.get_items().getItem(0).get_value());
Problem is when I have loaded the new items above into the webdropdown1, the alert value statement is still showing me the index 0 element which was there in the dropdown1 before loading the new items. Is there a problem that changes are not getting reflected in the client-side. The dropdown clearly shows the correct items have been loaded when I open the dropdown and look at the items. Do i need to change some property values of the webdropdown. Because, once I am able to retrieve the correct item after loading, then I can use your code to select that item.