Bind To MVC Hierachial Data Model

3 posts, 0 answers
  1. Or Huang
    Or Huang avatar
    4 posts
    Member since:
    Mar 2010

    Posted 22 Aug 2012 Link to this post

    Hi , 

    the data model structure the following :
    public class TreeMainItem
    {
       private IList<TreeSubItem> _SubItems;
       private bool _hasChildren =true;
     
       public TreeMainItem()
       
           _SubItems = new List<TreeSubItem>();
       }
     
       public int ItemIndex { get; set; }
       public string Title { get; set; }
       public string CssClass { get; set; }
       public string TargetUrl { get; set; }
       public string IconUrl { get; set; }
       public bool hasChildren
       {
          get { return this._hasChildren; }
          set { this._hasChildren = value; }
       }
       public IList<TreeSubItem> SubItems
       {
          get { return this._SubItems; }
          set { this._SubItems = value; }
       }
    }
     
    public class TreeSubItem
    {
       private bool _hasChildren = false;
        
       public int ItemIndex { get; set; }
       public string Title { get; set; }
       public string CssClass { get; set; }
       public string TargetUrl { get; set; }
       public string IconUrl { get; set; }
       public bool hasChildren
       {
          get { return this._hasChildren; }
          set { this._hasChildren = value; }
       }
    }

    I use Html.Kendo().TreeView().DataSource() , but treeview can't  render subitem , 

    how could I fix or use other method ?
  2. li
    li avatar
    3 posts
    Member since:
    Apr 2017

    Posted 12 May in reply to Or Huang Link to this post

    HI  Or Huang,

    Have you solved your problem?

    I have the same problem, and if your problem has been solved, can you share the solution?

     

  3. Ivan Danchev
    Admin
    Ivan Danchev avatar
    1091 posts

    Posted 17 May Link to this post

    Hello,

    See this demo which demonstrates the necessary mappings configuration needed for the hierarchy of items to be created. The server-side logic can be reviewed in the demo's source section. The two models used (CategoryItem and SubCategoryItem) are posted below:
    public class CategoryItem
    {
        public string CategoryName { get; set; }
        public List<SubCategoryItem> SubCategories { get; set; }
    }
     
    public class SubCategoryItem
    {
        public string SubCategoryName { get; set; }
    }


    Regards,
    Ivan Danchev
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top