This question is locked. New answers and comments are not allowed.
Hi,
I have a an mvc treeview that is initially rendered on the page through a partial view. This is working fine.
I have a combobox on the page and now I need to add a node to the tree based on the selection in the combobox.
I would like to do this in the client side but I couldn't find the right way to do it.
Can I add a node to an already existing node through client side?
This is the partial view of the treenode:
This is the Action method that returns the partial view:
Thanks you,
Oded Tal
I have a an mvc treeview that is initially rendered on the page through a partial view. This is working fine.
I have a combobox on the page and now I need to add a node to the tree based on the selection in the combobox.
I would like to do this in the client side but I couldn't find the right way to do it.
Can I add a node to an already existing node through client side?
This is the partial view of the treenode:
@model Model @(Html.Telerik().TreeView() .Name("TreeView") .Items(item => { item.Add() .Text(Model.Root.ParentName) .Value(Model.Root.Value) .HtmlAttributes(new { MId = Model.Root.Id, Type = Model.Root.Type }).Items(subItem => { for (int i = 0; i < Model.ChildNodes.Count; i++) { subItem.Add() .Text(Model.ChildNodes[i].Name) .Value(Model.ChildNodes[i].Value) .HtmlAttributes(new { MId= Model.ChildNodes[i].Id, Type = Model.ChildNodes[i].Type }); } }); }).ExpandAll(true) )This is the Action method that returns the partial view:
public ActionResult Hierarchy(int id, Type type) { var list = new List<Models.someType>(); var nodes = service.GetNodes(); HierarchyModel model = new HierarchyModel { Root = new HierarchyModel { Id = nodes[0].Id, Name = nodes[0].Name, Type = (Models.Type)nodes[0].Type, Level = nodes[0].Level, Lineage = nodes[0].Lineage }, ChildNodes = (from n in nodes where n.Level == 2 select new HierarchyModel { Id = n.Id, Name = n.Name, Type = (CompanyType)n.Type, Level = n.Level, Lineage = n.Lineage }).ToList() }; return PartialView("Hierarchy", model); }Thanks you,
Oded Tal