[CLOSED] RadioGroup events

  1. #1

    [CLOSED] RadioGroup events

    Hi,

    I use a simple RadioGroup:

    <ext:RadioGroup ID="radioGroup" runat="server" ColumnsNumber="1">
                                <Items>
                                    <ext:Radio ID="radio1" runat="server" >
                                    </ext:Radio>
                                    <ext:Radio ID="radio2" runat="server">
                                    </ext:Radio>
                                </Items>
                            </ext:RadioGroup>
    In the server code in an Ajax event, I call:

    radioGroup.SuspendEvents();
                    try
                    {
                        if ( value )
                        {
                            radio1.Checked = true;
                            radio2.Checked = false;
                        }
                        else
                        {
                            radio1.Checked = false;
    
                            radio2.Checked = true;
    
                        }
                    }
                    finally
                    {
                        radioGroup.ResumeEvents();
                    }
    Actually I also call SuspendEvents/ResumeEvents for each of the radios in the above code.

    Since the RadioGroup markup element does not expose Listeners tags, I subscribe in JavaScript to the RadioGroup 'change' event, but the 'change' event is called after the above Ajax event regardless of the fact that I have called SuspendEvents. Is there a setting for that or is it just not implemented?

    Regards,
    Tadeusz
  2. #2

    RE: [CLOSED] RadioGroup events

    Hi Tadeusz,

    Can you post a full .aspx sample demonstrating the scenario? You mention client-side listeners, but your sample does not demonstrate how you have the listeners configured.


    Geoffrey McGill
    Founder
  3. #3

    RE: [CLOSED] RadioGroup events

    Hi,

    There are few problems

    1. All fields using special function which set values as batch. Unfortunately it breaks script sequence. Therefore setValue for field calls early then 'suspendEvents' (in the developing 1.0 version we changed it and setValue use correct script sequence)

    2. RadioGroup fire 'change' with 10 ms delay (I don't know why, it is ExtJS original behaviour)

    Possible solutions:

    1. RadioGroup
    protected void Click1(object sender, AjaxEventArgs e)
            {
                radioGroup.SuspendEvents();
                try
                {
                    if (value)
                    {
                        radio1.Checked = false;
                        radio2.Checked = true;
                    }
                    else
                    {
                        radio1.Checked = false;
                        radio2.Checked = true;
                    }
                }
                finally
                {
                    radioGroup.AddScript("{0}.resumeEvents.defer(15, {0});", radioGroup.ClientID);
                }
            }
    2. CheckGroup (in 1.0 version your original example will works corrctly with CheckboxGroup, therefore the following workaround is not required for 1.0)
     protected void Click1(object sender, AjaxEventArgs e)
            {
                radioGroup.SuspendEvents();
                try
                {
                    if (true)
                    {
                        radio1.AddScript("{0}.setValue({1});", radio1.ClientID, true);
                        radio2.AddScript("{0}.setValue({1});", radio2.ClientID, false);
                    }
                    else
                    {
                        radio1.AddScript("{0}.setValue({1});", radio1.ClientID, false);
                        radio2.AddScript("{0}.setValue({1});", radio2.ClientID, true);
                    }
                }
                finally
                {
                    radioGroup.ResumeEvents();
                }
            }

    P.S. Now Radio/Checkbox groups has listeners and AjaxEvents
  4. #4

    RE: [CLOSED] RadioGroup events

    Hi,

    Thank you - that works great. Is something similar possible with checkboxes (for a Coolite version prior to 1.0)? I have a checkbox defined this way:

                          <ext:Checkbox runat="server" ID="checkbox" >
                                <AjaxEvents>
                                    <Check OnEvent="OnCheckDateChecked" />
                                </AjaxEvents>
                            </ext:Checkbox>
    In a different AjaxEvent than OnCheckDateChecked, I use the following code:

               checkbox.SuspendEvents();
                try
                {
                    checkbox.Checked = value;
                }
                finally
                {              
                   checkbox.ResumeEvents();
                  // the below doesn't work either
                  // checkbox.AddScript( "{0}.resumeEvents.defer(15, {0});", checkbox.ClientID );
                }
    However the OnCheckDateChecked gets called anyway after that. Is there a workaround too?


    Regards,
    Tadeusz
  5. #5

    RE: [CLOSED] RadioGroup events

    Hi,


    See Item 2 of my previous post. For checkboxes you need use AddScript (it save correct script sequence)


    check1.AddScript("{0}.setValue({1});", check1.ClientID, false);

  6. #6

    RE: [CLOSED] RadioGroup events

    Thanks a lot! Works perfect.

    Tadeusz

Similar Threads

  1. [CLOSED] RadioGroup Events
    By rnfigueira in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: May 23, 2013, 11:28 AM
  2. Replies: 15
    Last Post: Feb 03, 2011, 1:27 PM
  3. Replies: 4
    Last Post: Jul 17, 2010, 8:21 AM
  4. [CLOSED] [1.0] RadioGroup
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 08, 2010, 7:54 AM
  5. [CLOSED] RadioGroup needs help
    By jsemple in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Mar 12, 2009, 11:51 AM

Posting Permissions