This is a migrated thread and some comments may be shown as answers.
PanelBarItem Content problem!
1 Answer 32 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
xu
Top achievements
Rank 1
xu asked on 05 Jan 2012, 10:12 AM
my code:
@(Html.Telerik().PanelBar()
        .Name("PanelBar")
        .Items(items =>
        {
            foreach (PermissionCategory pc in permissionCategories)
            {
                items.Add()
                    .Text(pc.CategoryName + "  (" + pc.Permissions.Count.ToString() + ")")
                    .Content(
                        @<text>
                        @foreach (Permission p in pc.Permissions)
                        {
                            <input type="checkbox" name="SelectedPermissionIds" value="@p.Id"
                                @if (Model.SelectedPermissionIds != null && Model.SelectedPermissionIds.Contains(p.Id))
                                {
                                    <text>checked="checked"</text>
                                }   
                            />
                            @p.Name
                            <br />        
                        }
                        </text>);
            }

        }))

but the result is : all PanelBarItems have the same content, how to solve this? thanks!!!

1 Answer, 1 is accepted

Sort by
0
xu
Top achievements
Rank 1
answered on 05 Jan 2012, 12:31 PM
i solved the problem.

 @(Html.Telerik().PanelBar()
        .Name("PanelBar")
        .Items(items =>
        {
            foreach (PermissionCategory pc in permissionCategories)
            {
                items.Add()
                    .Text(pc.CategoryName + "  (" + pc.Permissions.Count.ToString() + ")")
                    .Content(
                    PanelBarItemContent(pc).ToHtmlString()
                     
    );
            }

        }))

@helper PanelBarItemContent(PermissionCategory pc)
{
    foreach (Permission p in pc.Permissions)
    {
        <input type="checkbox" name="SelectedPermissionIds" value="@p.Id"
            @if (Model.SelectedPermissionIds != null && Model.SelectedPermissionIds.Contains(p.Id))
            {
                <text>checked="checked"</text>
            }   
        />
        @p.Name
        <br />        
    }
}
Tags
PanelBar
Asked by
xu
Top achievements
Rank 1
Answers by
xu
Top achievements
Rank 1
Share this question
or