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.
Hello Sunil,
Since you are partially explaining your scenario every time could you please attach a whole running sample with steps to reproduce exactly the issue you are facing. We have documentation regarding cascading dropdowns - http://help.infragistics.com/Help/NetAdvantage/ASPNET/2012.1/CLR4.0/html/WebDropDown_Cascading_WebDropDown_Controls.html And a sample showing this scenario http://es.infragistics.com/products/aspnet/sample/drop-down/cascade and http://es.infragistics.com/products/aspnet/sample/drop-down/cascade-alternative Items requested event is called when filtering operation is performed on the client side – either automatically when the user is typing in the textbox or manually if you proogramatically call loadItems. If i undesrtand correctly your current issue is with the display value after loading new items - you did not point if you have tried the approach in my previous sample and how.
My scenario is bit different from your previous sample. Let me explain again:
When loadItems function is being called, I was expecting that an AJAX request will be generated and control should go to server-side. Once request is completed, AJAX response from server-side will be generated and control will come to client-side. But what I am able to see is that the entire code on the client-side is being executed first, then AJAX request is being sent to server-side.
I was thinking that the AJAX request will be generated as soon as loadItems statement is encountered and then after AJAX response, the remaining statements after the loadItems statement will be executed.
Hello SUnil,
What you are facing is the default behavior.
In that case, I am looking for a solution where I should be able to load the webdropdown on client-side rather than using loadItems to go to server-side.
May I know how I can handle the AJAX response on the client-side which comes back after "ItemsRequested" event on the server-side has been executed.
Hi Nikifor,
I don't have any other browser apart from IE. I am able to reproduce the behaviour with your sample. Please find your updated sample.
I have increased the number of items in webdropdown2 to 3 by adding "Z" value as well when "2" is selected in webdropdown1.
Also, I have added the below two lines in the AJAXResponse javascript function:
var ddLength = ig_controls.WebDropDown2.get_items().getLength(); alert("Number of items in webdropdown2:" + ddLength);
to check the number of items in webdropdown2 after AJAX Response comes. It shows the old values and not the count of newly loaded items.
I want to do some processing on the new items after getting the new items in the AJAX Response. but since this is not working, I am stuck here.
Is this behavior reproducible with the sample i have attached? Because i have tested this sample with FF 14, Opera 12, IE 9 and Chrome and none of the browsers shows this behavior. All the browsers show the new loaded values with the sample
I was asking for a solution to the AJAX response problem. Whatever solution you have given will not work till the AJAX response fix is done.
Problem Description: When ItemsRequested event is called and control goes to server-side to load a webdropdown with new values and after that, when a AJAX response comes to client-side, it still shows the old items in the response. When ItemsRequested event is called again, then the AJAX response shows the previous response and that's how it is working.
Ideal behaviour: When AJAX response is handled at client-side, it should show the newly loaded items so that validations can be done on the client-side for the new items.
Please provide some temporary solution to this problem if you don't have a permanent solution now. And when we can expect a permanent solution.
Hello Sunil,Please use this temporary workaround:
function mySelector() {
var dd = ig_controls.WebDropDown2;
if (dd.get_selectedItemIndex() > -1) {
dd.get_selectedItem().unselect();
}
dd.get_items().getItem(0).select();
var vtd = dd.get_items().getItem(0).get_text()
dd.set_currentValue(vtd,
true);
dd._elements[
"Input"].value = vtd;
Just checking to know how much time it will take to solve the issue? If it is going to take weeks, then please suggest some alternate solution/workaround for this issue.