Hi all.
i have webdropdown search and loadondemand.
when the search results are just one item. I want the item to be selected.
I've tried checking in DropDownClosing event. If there are 2 items (including blank item), the item second to be selected
but i can't get list item in this event or can't get value this item.
Please see demo behind and help me.
Thanks!
Hello Nguyen,
Thank you for your sample. I carefully followed your code and noticed this line:
var item = sender._elements["List"].childNodes[1];
This will return a
var item = sender.get_items()._items[1];
and then item.get_value() and item.get_text() will return the correct results.
Please see how this part of your code should look like:
Apart from this I am not sure what is the whole idea of the code in the DropDownClosing event. If you clarify these for me maybe I will be able to rewrite the whole function inside:
1) Do you want to check which is the selected item on dropDownClosing or you want to programmatically select an item ?
2) What do you want to do if the 2nd item is selected or after you have selected it in code ?
I hope this helps. If you answer my questions I will be glad to help you further.
Hello Hristo, thank your help.With your questions about idea of the code in the DropDownClosing event:
I want when I search on the dropdown. If the search results are 2 items, the 2nd item must be selected automatically without the user to select that item. If the search results more than 2 items. the user does not select item. webdropdown will set selected item value before search.
1) I want to programmatically select an item.2) When user close dropdown and don't selecte item. webdropdown will be set selected item.
In addition I have checked your code. it is true when the user selects one item but does not help in my case.
Please help me, thank you very much!