Help: Dynamically create checkboxes on window load
New Community Forums available at http://forums.ext.net
 

Coolite Forums

Welcome Guest ( Login | Register )
 
Help: Dynamically create checkboxes on window...
Subscribe
Last Login: 4/26/2010 7:00:20 AM
Posts: 25,
Posted 3/10/2010 1:40:08 AM

Group: Coolite Early Adopter
 Hi,

I use an ajax even to call a subroutine that loads a window,  i'm trying to remove the existing check boxes from a check box group and dynamically add new check boxes from a database but am having no luck

Any advice would be appreciated:

Markup:


<ext:Tab ID="RolesTab" runat="server" Title="Roles (Permissions)" Icon="UserKey" BodyStyle="padding:5px;">
                        <Body>
                            <ext:FormLayout ID="RolesFormLayout" runat="server" LabelWidth="125">
                                 <ext:Anchor Horizontal="99%">
                                      <ext:CheckboxGroup ID="RolesCBGroup" runat="server" ColumnsNumber="2" FieldLabel="Roles:" ItemCls="x-check-group-alt">
                                            <Items>
                                            <ext:Checkbox ID="test" FieldLabel="TestField" runat="server"></ext:Checkbox>
                                            </Items>
                                      </ext:CheckboxGroup>
                                 </ext:Anchor>
                           </ext:FormLayout>                           
                        </Body>
                    </ext:Tab>




VB Code behind:



 Public Sub PopulateAllRoles(ByVal user_name As String)

        'Define Roles Array
        Dim roles As String() = System.Web.Security.Roles.GetAllRoles()

        'Define ITEM
        Dim Item As Coolite.Ext.Web.Checkbox

        'Define Role ID Counter For Checkbox
        Dim RoleCBID As Integer = 0

        'Clear, Clean Up and Remove Existing Checkboxes (Possibly from previous use of the window)
        For Each component As Coolite.Ext.Web.Component In RolesCBGroup.Items
            RolesCBGroup.Controls.Remove(component)
            RolesCBGroup.LazyItems.Remove(component)
        Next

        'Loop to add All Roles
        For Each role As String In roles

            'Redifine as NEW Item
            Item = New Coolite.Ext.Web.Checkbox

            'Define ID
            Item.ID = "role" & RoleCBID
            'Define Field Label
            Item.FieldLabel = role
            'Set Visibility Of Control
            Item.Visible = "True"
            Item.Hidden = "False"

            'Define Current Value
            Item.Value = System.Web.Security.Roles.IsUserInRole(user_name, role)
            'Add CheckBox To Group
            RolesCBGroup.Controls.Add(Item)

            'Add 1 To CheckBox ID
            RoleCBID = (RoleCBID + 1)
        Next


    End Sub





Last Login: 4/26/2010 7:00:20 AM
Posts: 25,
Posted 3/12/2010 5:36:13 AM

Group: Coolite Early Adopter
 Has Anyone had any luck with this?
« Prev Topic | Next Topic »
Reading This Topic
Active Users: 0 ( 0 guests, 0 members, 0 anonymous members )
No members currently viewing this topic.
All times are GMT -5:00, Time now is 8:51pm