[CLOSED] on demand loads

  1. #1

    [CLOSED] on demand loads

    Support,
    I am trying to load two combos (separately). I want to load the stores when i first click the dropdown. Each click will load the store via an ajaxproxy and then expand the combo.

    I find the first one works well, but the second one opens and then closes.

    I tried to build an example but i dont have an external ajax proxy to use. The example is the best i can do for the forum. just replace the models with ajax proxy loads.

    Thanks,
    /Z

    <%@ Page Language="C#" %>
    
    
    <!DOCTYPE html>
    
    
    
    
    <html>
    <head id="Head1" runat="server">
        <link href="/resources/css/examples.css" rel="stylesheet" />    
    
    
    
    
            <style type="text/css">
            .red-text {
                color     : red;
                font-size : large;
            }
        </style>
    
    
        <script runat="server">
            protected void TestLoad(object sender, StoreReadDataEventArgs e)
            {
                this.Test1.Store.Primary.DataSource = new object[]
                {
                    new object[] { 1, "test1" },
                    new object[] { 2, "test2" },
                    new object[] { 3, "test3" }
                };
    
    
                this.Test1.Store.Primary.DataBind();
    
    
        
    
    
            }
            protected void TestLoad2(object sender, StoreReadDataEventArgs e)
            {
    
    
                this.ComboBox1.Store.Primary.DataSource = new object[]
                {
                    new object[] { 4, "test4" },
                    new object[] { 5, "test5" },
                    new object[] { 6, "test6" }
                };
    
    
                this.ComboBox1.Store.Primary.DataBind();
            }
    </script>
    
    
        <script>
            var runMe = function () {
                App.TESTSETET.show();
            };
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
            <ext:ResourceManager ID="ResourceManager1" runat="server">
                <Listeners>
                    <DocumentReady Handler="runMe()" />
                </Listeners>
            </ext:ResourceManager>
    
    
    
    
                    
    
    
    
    
        <ext:Window 
            ID="TESTSETET" 
            runat="server" 
            Icon="ApplicationFormAdd" 
            Width="500" 
            Hidden="true" 
            Modal="true"
            Layout="FitLayout"
            Title="TEST">
            <Items>
                <ext:FormPanel
                    ID="FormTEST" 
                    runat="server" 
                    Layout="VBoxLayout"
                    BodyPadding="5"
                    >
                    <Items>
                        <ext:ComboBox ID="Test1" 
                            runat="server"
                            DisplayField="description"
                            HideLabel="true"
                            ValueField="id"
                            QueryMode="Local"
                            EmptyText="Select ...">
                            <Store>
                                <ext:Store ID="Store1" runat="server" AutoLoad="false" OnReadData="TestLoad" >
                                    <Model>
                                        <ext:Model ID="Model1" IDProperty="id" runat="server">
                                            <Fields>
                                                <ext:ModelField Name="id" />
                                                <ext:ModelField Name="description" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                    <Sorters>
                                        <ext:DataSorter Property="description" Direction="ASC" />
                                    </Sorters>
                                </ext:Store>
                            </Store>                                            
                            <Triggers>
                                <ext:FieldTrigger Icon="Clear" Qtip="Remove selected" />
                            </Triggers>
                            <ListConfig LoadingText="Loading..." />
                            <Listeners>
                                <Focus Handler="#{Store1}.load();#{Test1}.expand();" Single="true" />
                                <TriggerClick Handler="this.clearValue();" />
                            </Listeners>
                        </ext:ComboBox>
                        <ext:ComboBox ID="ComboBox1" 
                            runat="server"
                            DisplayField="description"
                            HideLabel="true"
                            ValueField="id"
                            QueryMode="Local"
                            EmptyText="Select ...">
                            <Store>
                                <ext:Store ID="Store2" runat="server" AutoLoad="false"  OnReadData="TestLoad2">
                                    <Model>
                                        <ext:Model ID="Model2" IDProperty="id" runat="server">
                                            <Fields>
                                                <ext:ModelField Name="id" />
                                                <ext:ModelField Name="description" />
                                            </Fields>
                                        </ext:Model>
                                    </Model>
                                    <Sorters>
                                        <ext:DataSorter Property="description" Direction="ASC" />
                                    </Sorters>
                                </ext:Store>
                            </Store>                                            
                            <Triggers>
                                <ext:FieldTrigger Icon="Clear" Qtip="Remove selected" />
                            </Triggers>
                            <ListConfig LoadingText="Loading..." />
                            <Listeners>
                                <Focus Handler="#{Store2}.load();#{ComboBox1}.expand();" Single="true" />
                                <TriggerClick Handler="this.clearValue();" />
                            </Listeners>
                        </ext:ComboBox>
                    </Items>
                </ext:FormPanel>
            </Items>
        </ext:Window>
        </form>
    </body>
    </html>
    Last edited by fabricio.murta; Jun 12, 2017 at 11:15 AM.
  2. #2
    Hello @Z!

    You are so close with that test case from working! Just change the store load() calls to reload() and that's it.

    You may be asking yourself why now "reload". The answer is, because during the reload() call, it calls load() with the original options saved/set to properly load the store. So it effectively calls the TestLoad and TestLoad2 methods.

    This is, by the way, used in the Ajax linked combos example.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hello @Z!

    It's been some days since we replied you here and still no feedback from you. Do you still need assistance with this thread, or was the solution suggested enough for your issue?
    Fabrício Murta
    Developer & Support Expert
  4. #4
    thanks. you can close for now.
    /Z

Similar Threads

  1. [CLOSED] TreeNode load on demand
    By susanz in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 24, 2014, 3:41 PM
  2. Create component in JS on demand
    By ambruslaco in forum 1.x Help
    Replies: 3
    Last Post: Apr 19, 2013, 3:13 PM
  3. Label Icons on Demand
    By orozcoc in forum 1.x Help
    Replies: 6
    Last Post: Feb 10, 2011, 6:00 PM
  4. [CLOSED] Using UserControls as modules and load on demand
    By smart+ in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jul 22, 2010, 6:25 PM
  5. Load on demand combo box
    By jchau in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 03, 2008, 1:39 PM

Posting Permissions