This is a migrated thread and some comments may be shown as answers.

DataBindings with Checkboxes

2 Answers 76 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Sternico
Top achievements
Rank 1
Sternico asked on 23 Aug 2012, 11:59 AM
Hello,

I'm trying to create a menu with RadPanelBar for showing groups of services, each group with their services associated. This menu has two levels, the parent level with the name of the group, and the child level with the name of the service. Because the user can select multiple services into a group, the child must be a Checkbox, and here I have the problem.

At this moment I handle two options: I have a DataBindings with a RadPanelItemBinding that give me the structure parent-child with the data correctly formed, but without the checkboxes. I don't know how can I use another control into the DataBindings structure, neither if I can.

In the other side, I have an ItemTemplate with the Checkboxes doing the same, but it doesn't differentiate the information about the parent and the child.

  <telerik:RadPanelBar ID="RadPanelBar1" runat="server" ExpandMode="SingleExpandedItem" DataFieldID="ID" DataFieldParentID="ParentID" Width="90%">
            <DataBindings>
                <telerik:RadPanelItemBinding ImageUrlField="ImageUrl" TextField="Name" Expanded="True" ChildGroupHeight="200px" />
            </DataBindings>
             
            <ItemTemplate>
                <asp:CheckBox ID="CheckBox1" runat="server" Text='<%# ((ServicePanelbarContainer)Container.DataItem).Name %>'/>
            </ItemTemplate>
        </telerik:RadPanelBar>


I'm binding the data to the RadPanelBar with this structure.

Thanks for your help.

 int i = 1;
            foreach (ServiceGroup serviceGroup in groupList)
            {
                serviceGroup.ImageUrl = "../../Img/Icons/" + serviceGroup.ImageUrl;
 
                parsedGroupList.Add(new ServicePanelbarContainer()
                {
                    ParentID = 0,
                    ID = i,
                    Name = serviceGroup.Name,
                    ImageUrl = serviceGroup.ImageUrl
                });
                 
                int j = i;
                i++;
                 
                foreach (Service s in serviceGroup.Service)
                {
                    parsedGroupList.Add(new ServicePanelbarContainer()
                    {
                        ParentID = j,
                        ID = i,
                        Name = s.Name,
                        ImageUrl = ""
                    });
 
                    i++;
                }
            }

RadPanelBar1.DataSource = parsedGroupList;
RadPanelBar1.DataBind();

2 Answers, 1 is accepted

Sort by
0
Accepted
Kate
Telerik team
answered on 28 Aug 2012, 09:12 AM
Hello Sternico,

I prepared a very simplified runnable page where I implemented hierarchical databinding and applying templates to the child items only (as explained in the help article here).

Kind regards,
Kate
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Sternico
Top achievements
Rank 1
answered on 29 Aug 2012, 11:49 AM
Thanks Kate, it was enough. With a few changes it works fine as I want.

Regards.
Tags
PanelBar
Asked by
Sternico
Top achievements
Rank 1
Answers by
Kate
Telerik team
Sternico
Top achievements
Rank 1
Share this question
or