Hi,
I need to binding local data to treeview with data 3 level in razor. Can kendo UI work ?
Sample
public class Level1
{
public string RootName {get;set;}
public List<Level2> rootLevel2 {get;set;}
}
public class Level2
{
public string RootName { get; set; }
public List<Level3> rootLevel3 {get;set;}
}
public class Level3{
public string RootName { get; set; }
}
CSHTML Page view
@(Html.Kendo().TreeView()
.Name("rootView")
.BindTo((IEnumerable<Level1>)Model.Level1, (NavigationBindingFactory<TreeViewItem> mappings) =>
{
mappings.For<Level1>(binding => binding.ItemDataBound((item, root) =>
{
item.Text = root.RootName;
item.Expanded = true;
})
.Children(category => category.rootLevel2)
);
mappings.For<Level2>(binding => binding.ItemDataBound((item, root2) =>
{
item.Text = root2.RootName;
})
.Children(category => category.rootLevel3)
);
mappings.For<Level3>(binding => binding.ItemDataBound((item, root3) =>
{
item.Text = root3.ItemName;
}));
}))
There sample code above does not work for me, Always show error "Sequence contains no elements"
Thank you in advance.
I need to binding local data to treeview with data 3 level in razor. Can kendo UI work ?
Sample
public class Level1
{
public string RootName {get;set;}
public List<Level2> rootLevel2 {get;set;}
}
public class Level2
{
public string RootName { get; set; }
public List<Level3> rootLevel3 {get;set;}
}
public class Level3{
public string RootName { get; set; }
}
CSHTML Page view
@(Html.Kendo().TreeView()
.Name("rootView")
.BindTo((IEnumerable<Level1>)Model.Level1, (NavigationBindingFactory<TreeViewItem> mappings) =>
{
mappings.For<Level1>(binding => binding.ItemDataBound((item, root) =>
{
item.Text = root.RootName;
item.Expanded = true;
})
.Children(category => category.rootLevel2)
);
mappings.For<Level2>(binding => binding.ItemDataBound((item, root2) =>
{
item.Text = root2.RootName;
})
.Children(category => category.rootLevel3)
);
mappings.For<Level3>(binding => binding.ItemDataBound((item, root3) =>
{
item.Text = root3.ItemName;
}));
}))
There sample code above does not work for me, Always show error "Sequence contains no elements"
Thank you in advance.