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

Bind To MVC Hierachial Data Model

2 Answers 180 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Or Huang
Top achievements
Rank 1
Or Huang asked on 22 Aug 2012, 09:42 AM
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 Answers, 1 is accepted

Sort by
0
li
Top achievements
Rank 1
answered on 12 May 2017, 09:12 AM

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?

 

0
Ivan Danchev
Telerik team
answered on 17 May 2017, 08:04 AM
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.
Tags
TreeView
Asked by
Or Huang
Top achievements
Rank 1
Answers by
li
Top achievements
Rank 1
Ivan Danchev
Telerik team
Share this question
or