This question is locked. New answers and comments are not allowed.
With the help of the topics in this forum, I've been able to successfully bind my Model.IEnumerable<T> to a treeview, and I'm catching the checked box list in the controller (which has a parameter for the list). My question is how do I do this for multiple dynamically created treecontrols?
Also, is there a way to bind it directly to the model such that in the controller, the "Model" stays populated with the selection, rather than having a separate List<TreeViewItem> parameter. Does the KendoUI upgrade do that?
This is my controller, note the one parameter for the single treeview:
This is my view - my intention is to put this in a loop, and bind multiple dynamic treeviews:
Also, is there a way to bind it directly to the model such that in the controller, the "Model" stays populated with the selection, rather than having a separate List<TreeViewItem> parameter. Does the KendoUI upgrade do that?
This is my controller, note the one parameter for the single treeview:
[HttpPost] public ViewResult Search(AssetSearchModel model, string Search, string page, List<TreeViewItem> DomainTree_checkedNodes, string sort = "assetid", string order = "asc") { var button = Search; if (button == "Search") { HttpContext.Session["AssetSearchModel"] = null; } string message = string.Empty; if (DomainTree_checkedNodes != null) { foreach (TreeViewItem node in DomainTree_checkedNodes) { message += node.Text + "<br/>"; } } //ViewData["message"] = message; ViewData["DomainTree_checkedNodes"] = DomainTree_checkedNodes;.......}This is my view - my intention is to put this in a loop, and bind multiple dynamic treeviews:
List<TreeViewItem> checkedNodes = ViewData["DomainTree_checkedNodes"] as List<TreeViewItem>; @(Html.Telerik().TreeView().Name("DomainTree").ShowCheckBox(true) .BindTo(Model.SearchControls[y].DomainTree, mappings => { mappings.For<TreeItem>(binding => binding .ItemDataBound((item, treeitem) => { item.Value = treeitem.dcvid.ToString(); item.Text = treeitem.text; if (checkedNodes != null) { var checkedNode = checkedNodes .Where(e => e.Value.Equals(treeitem.dcvid.ToString())) .FirstOrDefault(); item.Checked = checkedNode != null ? checkedNode.Checked : false; } }) .Children(treeitem => treeitem.children));}));