[CLOSED] Load RadioGroup Item from database on Combo Select event

  1. #1

    [CLOSED] Load RadioGroup Item from database on Combo Select event

    Hi,
    I mam trying to load the RadioGroup items from database on Combo Select event. The Select event gets fired and Radio Items are also added to the RadioGroup but I can't see these Item in the RadioGroup on the page.
    I am using the following approach

    Markup
    <ext:ComboBox runat="server" ID="ddl" FieldLabel="Type" DisplayField="Name" ValueField="Id" DataIndex="Id">
    </ext:ComboBox>
    <ext:RadioGroup runat="server" ID="group" FieldLabel="Some Name" DataIndex="Id">
                    <Items>
                        <ext:Radio runat="server" ID="temp" Hidden="true">
                        </ext:Radio>
                    </Items>
    </ext:RadioGroup>
    Code Behind
    protected override void OnLoad(System.EventArgs e)
            {
                ddl.DirectEvents.Select.Event += ddl_Event;
                base.OnLoad(e);
            }
    
            void ddl_Event(object sender, Ext.Net.DirectEventArgs e)
            {
    this.group.Items.Clear();
                //get records from database and add items to RadioGroup one by one
                foreach (DataRow dataRow in dataView.Table.Rows)
                    {
                        this.group.Items.Add(new Radio { InputValue = dataRow["one"] + "", BoxLabel = dataRow["Two"] + "", Name = "SomeName",ID = "SomeId",GroupName = "groupName});
                    }
            }
    Looking for a quick response.
    Thanks
  2. #2

    RE: [CLOSED] Load RadioGroup Item from database on Combo Select event

    Hi,

    RadioGroup doesn't support adding items after rendering. It is ExtJS limitation. As you can see from ExtJS docs (http://www.extjs.com/deploy/dev/docs...orm.RadioGroup) there are no public methods to add/remove items to the group therefore you have to destory old group and create new

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    
        <script runat="server">
            protected void AddClick(object sender, EventArgs e)
            {
                this.group.Destroy();
    
                RadioGroup newGroup = new RadioGroup { ID = "newGroup", FieldLabel = "Some Name", DataIndex = "Id" };
                newGroup.Items.Add(new Radio { InputValue = "inpValue", BoxLabel = "label", Name = "SomeName", ID = "SomeId", GroupName = "groupName" });
                newGroup.InsertTo(0, FormPanel1);
            }
        </script>
    
    </head>
    <body>
        <form id="form1" runat="server">
        <ext:ResourceManager ID="ResourceManager1" runat="server">
        </ext:ResourceManager>
        <ext:Button runat="server" Text="Add">
            <DirectEvents>
                <Click OnEvent="AddClick" />
            </DirectEvents>
        </ext:Button>
        <ext:FormPanel ID="FormPanel1" runat="server">
            <Items>
                <ext:RadioGroup runat="server" ID="group" FieldLabel="Some Name" DataIndex="Id">
                    <Items>
                        <ext:Radio runat="server" ID="temp" Hidden="true">
                        </ext:Radio>
                    </Items>
                </ext:RadioGroup>
                <ext:TextField runat="server" FieldLabel="TextField" />
            </Items>
        </ext:FormPanel>
        </form>
    </body>
    </html>

Similar Threads

  1. Replies: 1
    Last Post: Jun 28, 2012, 9:39 PM
  2. Clear RadioGroup checked item
    By chunhuxiao in forum 1.x Help
    Replies: 0
    Last Post: Apr 26, 2012, 6:34 AM
  3. RadioGroup bug getting the selected item
    By paul-2011 in forum 1.x Help
    Replies: 1
    Last Post: Apr 06, 2011, 2:21 PM
  4. Replies: 3
    Last Post: May 11, 2010, 10:36 AM
  5. Replies: 0
    Last Post: Mar 09, 2010, 7:28 AM

Posting Permissions