[CLOSED] dynamically binding a control's store to new dataset

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    [CLOSED] dynamically binding a control's store to new dataset

    Hi Ext.net,

    Having trouble getting my multiselect combo to reflect any new data dynamically bound to a control (e.g. multicombo).
    I've abstracted the issue out to this simple example below and included some inline comments that specify the problems.
    Any ideas on what I'm missing? This should be trivial, so must be something obvious. Thanks.

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>MultiCombo - Ext.NET Examples</title>    
    
    <script runat="server">
        private object TestData1
        {
            get
            {
                return new object[]
                {
                    new object[] { "1A", "AVal1" },
                    new object[] { "1B", "AVal2" },
                    new object[] { "1C", "AVal3" },
                    new object[] { "1D", "AVal4" },
                    new object[] { "1E", "AVal5" },
                    new object[] { "1F", "AVal6" }
                };
            }
        }
    
        private object TestData2
        {
            get
            {
                return new object[]
                {
                    new object[] { "2A", "BVal1" },
                    new object[] { "2B", "BVal2" },
                    new object[] { "2C", "BVal3" },
                    new object[] { "2D", "BVal4" },
                    new object[] { "2E", "BVal5" },
                    new object[] { "2F", "BVal6" }
                };
            }
        }
    
        protected override void OnLoad(EventArgs e)
        {
            this.TestCombo.GetStore().DataSource = TestData1;
            this.TestCombo.GetStore().DataBind();
            //during OnLoad of Page's lifecycle, am able to get the comboboxes to reflect whatever dataset I bind against its store's datasource
    
            this.explicitStore.DataSource = TestData1;
            this.explicitStore.DataBind();
    
        }
    
        //should work b/c any call backs to non-static serverside methods should cause the Page lifecycle to execute and allow access to all page's web controls
        [DirectMethod]
        public void DM_RefreshMultiCombo()
        {
            this.TestCombo.GetStore().DataSource = TestData2;
            this.TestCombo.GetStore().DataBind();
            
    
            this.explicitStore.DataSource = TestData2;
            this.explicitStore.DataBind();
    
            //unfortunately DirectMethod unable to get the multi combos to reflect 2nd dataset
        }
    
        //should also work b/c any call backs to non-static serverside methods should cause the Page lifecycle to execute and allow access to all page's web controls
        protected void DE_RefreshMultiCombo(object sender, DirectEventArgs e)
        {
            this.TestCombo.GetStore().DataSource = TestData2;
            this.TestCombo.GetStore().DataBind();        
    
            this.explicitStore.DataSource = TestData2;
            this.explicitStore.DataBind();
    
            //DirectEvent handler also unable to get the multi combos to reflect 2nd dataset
        }
    </script>
        
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />        
    
            <ext:MultiCombo runat="server" ID="TestCombo" SelectionMode="Selection" DisplayField="name" ValueField="abbr">
                 <Store>
                        <ext:Store runat="server">
                            <Model>
                                <ext:Model runat="server">
                                    <Fields>
                                        <ext:ModelField Name="abbr" />
                                        <ext:ModelField Name="name" />                                    
                                    </Fields>
                                </ext:Model>
                            </Model>
    
                            <Reader>
                                <ext:ArrayReader />
                            </Reader>
                        </ext:Store>
                    </Store>                        
            </ext:MultiCombo>
            <br />
            
            <ext:MultiCombo runat="server" ID="ExplicitStoreCombo" SelectionMode="Selection" DisplayField="name" ValueField="abbr">
                 <Store>
                        <ext:Store ID="explicitStore" runat="server">
                            <Model>
                                <ext:Model runat="server">
                                    <Fields>
                                        <ext:ModelField Name="abbr" />
                                        <ext:ModelField Name="name" />                                    
                                    </Fields>
                                </ext:Model>
                            </Model>
    
                            <Reader>
                                <ext:ArrayReader />
                            </Reader>
                        </ext:Store>
                    </Store>                        
            </ext:MultiCombo>
            <br />
    
            <ext:Button
                ID="Button1"
                runat="server"            
                Text="Load MultiCombo w/ DirectMethod"
                >
                <Listeners>
                    <Click Handler="App.direct.DM_RefreshMultiCombo();" />
                </Listeners>            
            </ext:Button>
    
            <ext:Button
                ID="Button2"
                runat="server"            
                Text="Load MultiCombo w/ DirectEvent"            
                >
                <DirectEvents>
                    <Click OnEvent="DE_RefreshMultiCombo" />
                </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>
    Last edited by fabricio.murta; Oct 25, 2018 at 8:39 PM.

Similar Threads

  1. [CLOSED] Convert Dataset to Store
    By mapperez in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: May 21, 2014, 5:29 AM
  2. Replies: 2
    Last Post: Sep 27, 2011, 7:25 AM
  3. Replies: 7
    Last Post: Jun 03, 2011, 9:18 PM
  4. [CLOSED] store to dataset
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Apr 29, 2009, 9:48 AM
  5. Replies: 2
    Last Post: Oct 19, 2008, 11:48 PM

Posting Permissions