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 SUnil,
What you are facing is the default behavior.
Hi,
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,
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.
Also, to add into this, I am not sure how the "OnitemsRequested" event works. But what I am able to see is. first the entire javscript code is getting executed and then the control goes to the server-side function called on "ItemsRequested" event. I was assuming that when
$find("webdropdown2").loadItems(e.getNewSelection()[0].get_value(), false);
is executed, control will immediately go to the server-side. After executing the "OnItemsRequested" event, the control will return to the client-side after the loaditems statement.
To elaborate, take an example I have two webdropdowns:
"webdropdown1" which has two items:
0100 POLITICS
0200 SCIENCE
"webdropdown2' which has
"0101 NEW JERSEY" and "0102 NEW YORK" items which will be loaded when "0100 POLITICS" will be selected in "webdropdown1".
"0201 BIOLOGY" and "0202 PHYSICS" items which will be loaded when "0200 SCIENCE" will be selected in "webdropdown1".
I am using a SelectionChanged event on webdropdown1, so that when the selection changes, the corresponding items will be loaded into webdropdown2. I am using a server-side function in VB to load the items into webdropdown2 which is called on "OnItemsRequested" event.
aspx code:
<ig:WebDropDown id="webdropdown1" runat="server" cssclass="igdd_Control" Height="12px" Width="375px" EnableAnimations="False" EnableCustomValues="False" AutoSelectOnMatch="False" EnableAutoFiltering="Client">
<ClientEvents SelectionChanged="loadWebdropdown2"/></ig:WebDropDown>
<ig:WebDropDown id="webdropdown2" runat="server" cssclass="igdd_Control" Height="12px" Width="365px" EnableAnimations="False" EnableCustomValues="False" OnItemsRequested="webdropdown2_OnItemsRequested"></ig:WebDropDown>
Code-behind VB code:
Protected Sub webdropdown2_OnItemsRequested(ByVal sender As Object, ByVal e As Infragistics.Web.UI.ListControls.DropDownItemsRequestedEventArgs)
Code to load webdropdown2
End Sub
Javascript-code(client-side):
function loadWebdropdown2(sender, e) {
var webdropdown2_txt = $find("webdropdown2").get_items().getItem(1).get_text();
alert("webdropdown2_txt:" + webdropdown2_txt); }
Issue: When I select "0100 POLITICS" from webdropdown1, then "0101 NEW JERSEY" and "0102 NEW YORK" items are getting loaded correctly in webdropdown2.
After that, when I select "0200 SCIENCE" from webdropdown2, then "0201 BIOLOGY" and "0202 PHYSICS" items are getting loaded correctly in webdropdown2. But webdropdown2_txt displays text as "0102 NEW YORK" whereas "0202 PHYSICS" is expected.
I am not sure what may be the problem. How to make sure that AJAX response is coming correctly.