Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
411
DropDown gone WILD!
posted

I am using the script below and it is constantly posting back to the server requesting items. How do I make this stop??!

HTML

 

    <script type="text/javascript">

        function fillProducts(sender, evntArgs) {

            if (sender.get_items().get_length() == 0) {

                sender.loadItems();

            }

        }

    </script>

    <asp:ScriptManager ID="ScriptManager1" runat="server"/>

 

    <ig:WebDropDown ID="WebDropDown1" TextField="Product" ValueField="Product" 

        runat="server" Width="200px" 

        onitemsrequested="WebDropDown1_ItemsRequested" EnableAnimations="False" 

        EnableDropDownAsChild="False" EnableRenderingAnchors="False">

        <DropDownItemBinding TextField="Product" ValueField="Product" />

        <ClientEvents DropDownOpening="fillProducts" />

    </ig:WebDropDown>

 

 

Code Behind

 

    protected void WebDropDown1_ItemsRequested(object sender, Infragistics.Web.UI.ListControls.DropDownItemsRequestedEventArgs e)

    {

        SqlDataSource products = new SqlDataSource();

        products.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["WebApplicationsConnectionString"].ConnectionString;

        products.SelectCommand = "SELECT DISTINCT Product FROM Quote_Price_List WHERE Type=1";

 

        ((Infragistics.Web.UI.ListControls.WebDropDown)sender).DataSource = products;

        ((Infragistics.Web.UI.ListControls.WebDropDown)sender).DataBind();

    }

 

edit:

this same thing is happening with the 10.1 release...

 

  • 24671
    Verified Answer
    posted

    Hi,

    Do not use DropDownOpening, but the "Focus" client-side event.

    <ClientEvents Focus="fillProducts" />

    The issue in detail, is that once loadItems() is completed, and there are items returned, the dropdown is automatically opened, which calls dropDownOpening again, and an endless loop happens. In the latest service release (and in 10.1 as well), we have added a second parameter to loadItems which specifies whether the dropdown should be opened automatically or not:

    sender.loadItems("", false); // where the first parameter is the filter value,i'm using empty string so that it retrieves everything 

    Hope it helps,

    Angel