[CLOSED] Prevent default action in radio group not working

  1. #1

    [CLOSED] Prevent default action in radio group not working

    Hello, why is this not working? (the radio gets selected every time, it shouldn't)


    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
            }
        }
    
    </script>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title></title>
    
        <script type="text/javascript">
            var change = function (item) {
                console.debug(item);
            };
        </script>
    
    </head>
    <body>
        <ext:ResourceManager runat="server" />
    
        <ext:RadioGroup runat="server" FieldLabel="Rating" ColumnsNumber="3" AutomaticGrouping="false">
            <Items>
                <ext:Radio runat="server" Name="rating" InputValue="0" BoxLabel="A" ReadOnly="false" />
                <ext:Radio runat="server" Name="rating" InputValue="1" BoxLabel="B" ReadOnly="false" />
                <ext:Radio runat="server" Name="rating" InputValue="2" BoxLabel="C" ReadOnly="false" />
            </Items>
    
            <Listeners>
                <Change Handler="change(item);" PreventDefault="False" StopEvent="True" StopPropagation="True"></Change>
            </Listeners>
        </ext:RadioGroup>
    </body>
    </html>
    Last edited by Daniil; Nov 17, 2015 at 4:35 PM. Reason: [CLOSED]
  2. #2
    Hi @exe,

    I think the Change event fires when a Radio's state is already changed and the event is not meant to be able to prevent it.

    As far as I can see there is no BeforeChange event in API.

    I can suggest this solution.
    <ext:Radio ...>
        <Listeners>
            <AfterRender Handler="this.onBoxClick = Ext.Function.createInterceptor(this.onBoxClick, beforeOnBoxClick);" />
        </Listeners>
    </ext:Radio>
    var beforeOnBoxClick = function (e) {
        if (true) { // Prevent condition
            return false;
        }
    };
  3. #3
    The workaround is working as expected.

    Thanks!

Similar Threads

  1. [CLOSED] Prevent default action
    By exe in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 21, 2015, 11:59 AM
  2. Default Listeners on Radio Group [RAZOR]
    By dangerlinto in forum 2.x Help
    Replies: 0
    Last Post: Mar 11, 2015, 1:54 PM
  3. [CLOSED] Highlight Checked Radio Button in Radio Button Group
    By rcombis in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 06, 2014, 7:26 PM
  4. Retrieve checked radio from Radio Group
    By ttharaka2002 in forum 1.x Help
    Replies: 0
    Last Post: Mar 25, 2010, 2:15 AM
  5. [CLOSED] Dynamic Creation of Radio Buttons within Radio Group
    By Steve in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Mar 04, 2009, 1:13 PM

Tags for this Thread

Posting Permissions