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

How to add check box in PanelBar

2 Answers 355 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Umesh
Top achievements
Rank 1
Umesh asked on 06 Mar 2014, 07:36 AM
Hi 
How to add check box in panelbar item and binding data from entity framework.  

2 Answers, 1 is accepted

Sort by
0
Umesh
Top achievements
Rank 1
answered on 06 Mar 2014, 08:37 AM
Please check below code :

@(Html.Kendo().PanelBar()
    .Name("PanelBar")
    .HtmlAttributes(new { Styles = "width:10px" })
    .BindTo(Model, mappings =>
    {
        mappings.For<Header_PanelVM>(binding => binding
                .ItemDataBound((item, category) =>
                {
                    item.Text = category.HeaderName;
                    item.HtmlAttributes["id"] = category.HeaderName;

                })
                .Children(category => category.HList));
        mappings.For<HeaderList>(binding => binding
        .ItemDataBound((item, hearList) =>
        {
            item.Text = hearList.HeaderName;
            item.HtmlAttributes["onclick"] = "SelectChild('" + hearList.ParentHeaderName + "'," + hearList.HeaderId.ToString() + ")";

        }));
    })
    
)
in that i want to add check box,
please help me how i add it to item
0
Petur Subev
Telerik team
answered on 10 Mar 2014, 09:00 AM
Hello Umesh,

Basically the MVC helper does not allow you to inject HTML as a template or something. However you can turn the Encoded option to false and insert the html inside the Text of the item.

e.g.

panelbar.Add().Text("Fourth Item")
    .Items(items =>
    {
        items.Add().Text("Sub Item 1");
        items.Add().Text("<input type='checkbox' /> Sub Item 2").Encoded(false);

The same approach can be applied to your case when using the BindTo builder.

Kind Regards,
Petur Subev
Telerik

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

Tags
PanelBar
Asked by
Umesh
Top achievements
Rank 1
Answers by
Umesh
Top achievements
Rank 1
Petur Subev
Telerik team
Share this question
or