This question is locked. New answers and comments are not allowed.
I am trying to get TreeViewItems that are loaded on demand to have their URL open in a new window/tab when they are clicked. I am using a JSON call to a method that builds an array of TreeViewItems and i am adding the target as a LinkHtmlAttribute, but it is not working and that property is not being returned n the JSON object.
View (Initial TreeView) - Incidentally the target="_blank" works for these parent TreeViewItems
Controller
Here is one of the TreeViewItems copied from Firebug to show that the LinkHtmlAttributes isn't included.
Any help would be appreciated.
View (Initial TreeView) - Incidentally the target="_blank" works for these parent TreeViewItems
<%= Html.Telerik().TreeView() .Name("TreeView") .BindTo(Model.Categories, (item, c) => { item.Text = c.Name; item.Value = c.ID.ToString(); item.LoadOnDemand = !c.IsProductCategory; item.Url = "/Maintenance/EditCategory/" + c.ID.ToString(); item.Enabled = true; item.LinkHtmlAttributes.Add("target", "_blank"); }) .DataBinding(dataBinding => dataBinding .Ajax().Select("TreeBranch", "Maintenance") )%>Controller
[ActionName("TreeBranch"), AcceptVerbs(HttpVerbs.Post)] public ActionResult TreeBranch(TreeViewItem node) { AdminCategoryService.CategoryServiceClient csc = new AdminCategoryService.CategoryServiceClient(); ProductMaintenanceModel pmm = new ProductMaintenanceModel(); int? id = !string.IsNullOrEmpty(node.Value) ? (int?)Convert.ToInt32(node.Value) : null; if (id != null) { pmm.Categories = csc.GetSubCategories(Convert.ToInt32(id)); TreeViewItem[] nodes = new TreeViewItem[pmm.Categories.Length]; for (int i = 0; i < pmm.Categories.Length; i++) { nodes[i] = new TreeViewItem(); nodes[i].Text = pmm.Categories[i].Name; nodes[i].Value = pmm.Categories[i].ID.ToString(); nodes[i].LoadOnDemand = !pmm.Categories[i].IsProductCategory; nodes[i].Url = "/Maintenance/EditCategory/" + pmm.Categories[i].ID.ToString(); nodes[i].Enabled = true; nodes[i].LinkHtmlAttributes.Add("target", "_blank"); } return Json(nodes); } return null; }Here is one of the TreeViewItems copied from Firebug to show that the LinkHtmlAttributes isn't included.
{"Items":[],"Value":"456","Expanded":false,"Checked":false,"Checkable":true,"LoadOnDemand":true,"Encoded":true,"ImageUrl":null,"SpriteCssClasses":null,"Text":"Shipping Supplies","Selected":false,"Enabled":true,"Url":"/Maintenance/EditCategory/456"}Any help would be appreciated.