Building PanelBar Children Rescursively and Binding to Model

2 posts, 0 answers
  1. Carrie
    Carrie avatar
    27 posts
    Member since:
    Aug 2013

    Posted 18 Sep 2013 Link to this post

    Hello,

    Is it possible to have the panelbar nesting be recursive?   Let's say we are binding to a list of objects inside the model like this:
    public class Activity
       {
           public string ActivityId { get; set; }
           public string Description { get; set; }
           public List<Activity> Activities { get; set; }       
       }
  2. Daniel
    Admin
    Daniel avatar
    2118 posts

    Posted 20 Sep 2013 Link to this post

    Hello Carrie,

    This is the default binding behavior when the child items type is the same. You should just specify the mapping for the type and how the children can be accessed:

    @(Html.Kendo().PanelBar()
          .Name("panelbar")
          .BindTo(Model, mappings =>
           {
               mappings.For<Activity>(binding => binding
                   .ItemDataBound((item, activity) =>
                       {
                            item.Text = activity.Description;
                       })
                   .Children(activity => activity.Activities));
           })
    )
    Regards,
    Daniel
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top