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 answers.
I assume that by "search results" you mean the items visible in the drop down list. I hope I have understood you correctly and I have slightly changed the function you execute in order to work for your scenario.
Please have a look and let me know if there is something I am missing or I did not understand.
Here is a brief overview how this function works when closing the drop down:
1) If there is any item active(selected), its value and text are assigned to the HD_Entity_ID and HD_Entity_Name inputs. // line 3 - 12
2) If no item is active(selected) // line 26
I hope this helps. Please let me know if this logic correctly follows your scenario of if it needs some changes.
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!
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.