[CLOSED] Unable to set radio value using form.SetValues, if radio is in RadioGroup

  1. #1

    [CLOSED] Unable to set radio value using form.SetValues, if radio is in RadioGroup

    Hello.

    I tried to set values for radios using form's setValues method
    <ext:FormPanel ID="form" runat="server">
            <Items>
                <ext:RadioGroup runat="server">
                    <Items>
                        <ext:Radio runat="server" Name="f1" BoxLabel="f1" />
                        <ext:Radio runat="server" Name="f2" BoxLabel="f1" />
                    </Items>
                </ext:RadioGroup>
            </Items>
        </ext:FormPanel>
        <script type="text/javascript">
            Ext.onReady(function () {
                var form = <%=form.ClientID %>;
                form.getForm().setValues({
                    f1: true,
                    f2: false
                });
            });
        </script>
    I was able to set radio state in this way using Ext.Net 1.x, but now this does not work.

    Could you suggest a way to do this?

    Best regards.
    Last edited by Daniil; Sep 25, 2012 at 10:39 AM. Reason: [CLOSED]
  2. #2
    Hi,

    I tested the code. It appears to don't work in Ext.NET v1.

    Example
    <%@ 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>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:FormPanel ID="FormPanel1" runat="server">
                <Items>
                    <ext:RadioGroup runat="server">
                        <Items>
                            <ext:Radio runat="server" Name="f1" BoxLabel="f1" />
                            <ext:Radio runat="server" Name="f2" BoxLabel="f1" />
                        </Items>
                    </ext:RadioGroup>
                </Items>
            </ext:FormPanel>
    
            <script type="text/javascript">
                Ext.onReady(function () {
                    FormPanel1.getForm().setValues({
                        f1: true,
                        f2: false
                    });
                });
            </script>
        </form>
    </body>
    </html>
    Generally, RadioGroup can't contain Radios with different Names, because it will stop behave as a group, but it is the RadioGroup's destination.

    So, please clarify the requirement. Do you need these two Radios behaving as a group or not?
  3. #3
    It is needed that only one radio could be selected at time. So, yes, I need that these radios behave as a group. But I would like to have an opportunity to set needed radio using form's setValues method. Assume that I have 3 and more radios in a radio group and I have literal value, which indicates particular radio, which should be selected. (For example, 'Field_{i}', where {i} is sequence number of the field) .Is there any way to set particular radio checked?
  4. #4
    Then Radio should have the same "name" HTML attribute. Then they will behave as a group.

    Here is the example, please investigate.

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    
        <script type="text/javascript">
            var set = function (inputValue) {
                var fp = App.FormPanel1;
    
                fp.getForm().setValues({
                    RadioGroup1 : {  // it is a field ConfigID
                        RadioGroup1 : inputValue  // here is a GroupName
                    }
                });
            };
        </script>
    </head>
    <body>
        <ext:ResourceManager runat="server" />
            
        <ext:FormPanel ID="FormPanel1" runat="server">
            <Items>
                <ext:RadioGroup 
                    ID="RadioGroup1" 
                    runat="server" 
                    GroupName="RadioGroup1"
                    ColumnsNumber="1" >
                    <Items>
                        <ext:Radio runat="server" BoxLabel="Radio 1" InputValue="1" />
                        <ext:Radio runat="server" BoxLabel="Radio 2" InputValue="2" />
                    </Items>
                </ext:RadioGroup>
            </Items>
        </ext:FormPanel>
    
        <ext:Button runat="server" Text="Set 1">
            <Listeners>
                <Click Handler="set('1');" />
            </Listeners>
        </ext:Button>
    
        <ext:Button runat="server" Text="Set 2">
            <Listeners>
                <Click Handler="set('2');" />
            </Listeners>
        </ext:Button>
    </body>
    </html>
  5. #5
    Thank you, Daniil. Your example is very helpful for me. I was able to implement needed logic.

Similar Threads

  1. [CLOSED] RadioGroup - want each radio option on new line
    By PhilG in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 03, 2012, 2:53 PM
  2. Align boxlabel next ti radio in radiogroup
    By bjones in forum 1.x Help
    Replies: 0
    Last Post: Feb 07, 2012, 10:42 AM
  3. [CLOSED] Get value radio in radiogroup
    By nhg_itd in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 20, 2011, 9:37 AM
  4. Radiogroup radio boxlabel text not showing
    By Richardt in forum 1.x Help
    Replies: 4
    Last Post: Jan 19, 2010, 9:46 AM

Posting Permissions