[CLOSED] Adding Item to Checkbox group by Direct Event

  1. #1

    [CLOSED] Adding Item to Checkbox group by Direct Event

    Hey,

    I am unable to add Items to Checkbox Group through Direct Event.


    So if I have
    chkGroup.Items.Add(chk);

    It will work on Page load, but not in Direct Event Ajax Request. I think you will not need an example for this, it looks pretty straightforward.


    Thanks,
    Last edited by Daniil; Jan 12, 2012 at 11:47 AM. Reason: Please use [CODE] tags
  2. #2

    RE: [CLOSED] Adding Item to Checkbox group by Direct Event

    Hi,

    Unfortunatelly, Checkbox/Radio groups don't support adding/removing items after rendering. It is ExtJS limitation.
    I can suggest to rerender group during direct event (use Render, AddTo or InsertTo methods)
  3. #3

    RE: [CLOSED] Adding Item to Checkbox group by Direct Event

    Should I re render after adding items or before adding items?

    Can u give me a small example...
  4. #4

    RE: [CLOSED] Adding Item to Checkbox group by Direct Event

    Hi,

    Please see the following sample
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void AddCheckboxClick(object sender, DirectEventArgs e)
        {
            ((Ext.Net.Button)sender).Disabled = true;
            CheckboxGroup1.Items.Add(new Checkbox { BoxLabel = "Checkbox 4", Checked = true });
            CheckboxGroup1.Render(CheckboxGroup1.ContainerID, RenderMode.RenderTo);
        }
    
        protected void AddAnotherCheckboxClick(object sender, DirectEventArgs e)
        {
            ((Ext.Net.Button)sender).Disabled = true;
            // we have to recreate any previous dynamic added checkboxes
            CheckboxGroup1.Items.Add(new Checkbox { BoxLabel = "Checkbox 4", Checked = true });
            CheckboxGroup1.Items.Add(new Checkbox { BoxLabel = "Checkbox 5", Checked = true });
            CheckboxGroup1.Render(CheckboxGroup1.ContainerID, RenderMode.RenderTo);
        }
    </script>
    <!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:CheckboxGroup 
                ID="CheckboxGroup1" 
                runat="server" 
                ColumnsNumber="1">
                <Items>
                    <ext:Checkbox runat="server" BoxLabel="Checkbox 1" />
                    <ext:Checkbox runat="server" BoxLabel="Checkbox 2" />
                    <ext:Checkbox runat="server" BoxLabel="Checkbox 3" />
                </Items>
            </ext:CheckboxGroup>
            <ext:Button 
                runat="server" 
                Text="Add checkbox" 
                OnDirectClick="AddCheckboxClick" />
            <ext:Button 
                runat="server" 
                Text="Add another checkbox" 
                OnDirectClick="AddAnotherCheckboxClick" />
        </form>
    </body>
    </html>
    Last edited by Daniil; Jan 12, 2012 at 11:48 AM.
  5. #5

    RE: [CLOSED] Adding Item to Checkbox group by Direct Event

    Thanks!
  6. #6

    RE: [CLOSED] Adding Item to Checkbox group by Direct Event

    Now I get the error "Lazy Control can be rendered with Automatic Render Mode Only."

    My CHeckbox group is inside a Drop Down Field which is under a Tab. Tab is not Active.
  7. #7

    RE: [CLOSED] Adding Item to Checkbox group by Direct Event

    Hi,

    If group is lazy then you have to use Render without any arguments

Similar Threads

  1. Replies: 2
    Last Post: May 21, 2012, 9:25 AM
  2. Replies: 1
    Last Post: Mar 29, 2012, 9:52 AM
  3. [CLOSED] adding direct event to CommandColumn
    By Sevilay Tanış in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 23, 2012, 2:37 PM
  4. [CLOSED] Radio Group not submitting selection during Direct Event
    By vedagopal2004 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 07, 2011, 4:17 PM
  5. [CLOSED] Adding Checkbox items to checkbox group during a postback?
    By vedagopal2004 in forum 1.x Legacy Premium Help
    Replies: 19
    Last Post: Feb 05, 2010, 10:13 AM

Tags for this Thread

Posting Permissions