// // GET: /TreeView/Create public ActionResult Create(int? parentId) { var model = new Node(); model.Parent = SampleData.Nodes.First(p => p.Id == parentId); return View(model); }
private static string MakeLitteralRemove(Node node) { //<li class="treeview-node-tools"><img src="../../Images/Icons/trash.png" onclick="remove(@node.Id)" alt="remove"/></li> var li = new TagBuilder("li"); li.AddCssClass("treeview-node-tools"); li.InnerHtml = string.Format("<img alt=\"{0}\" src=\"{1}\" onclick=\"remove({2})\"/>", "remove", "../../Images/Icons/trash.png", node.Id); return li.ToString(); }
private static string MakeLitteralExpand(Node node) { //<li class="treeview-node-expand" onclick="expand(@node.Id)"><img src="../../Images/Icons/add.png"/></li> var li = new TagBuilder("li"); li.AddCssClass("treeview-node-expand"); li.Attributes.Add("onclick", string.Format("expand({0})", node.Id)); li.InnerHtml = string.Format("<img src=\"{0}\"/>", "../../Images/Icons/add.png"); return li.ToString(); }
private static string MakeLitteralTitle(Node node) { //<li onclick="onClickNode(@node.Id)" title="@node.Tooltip">@node.Title</li> var li = new TagBuilder("li"); li.Attributes.Add("onclick", string.Format("onClickNode({0})", node.Id)); li.Attributes.Add("title", node.Tooltip); li.InnerHtml = node.Title; return li.ToString(); }
private static string MakeNodeElement(Node node) { var ul = new TagBuilder("ul"); ul.AddCssClass("treeview-node-element"); var expandLi = MakeLitteralExpand(node); var titleLi = MakeLitteralTitle(node); var addLi = MakeLitteralAdd(node); var editLi = MakeLitteralEdit(node); var removeLi = MakeLitteralRemove(node); ul.InnerHtml = expandLi + titleLi + addLi + editLi + removeLi; return ul.ToString(); }