Exemple #1
0
        private static string Branch <T>(this HtmlHelper <OrgNode <T> > html, OrgNode <T> node, bool isRoot = false)
        {
            string classNames = string.Empty;

            if (isRoot)
            {
                classNames += "root";
            }
            if (node.Children.Count == 0)
            {
                classNames += "leaf";
            }
            if (classNames.Length > 0)
            {
                classNames = $" class='{classNames}'";
            }

            string htmlOutput = string.Empty;

            htmlOutput += $"<li{classNames}>";
            htmlOutput += "<div class='nodecontent'>";
            //htmlOutput += new HtmlHelper<T>(html.ViewContext, html.ViewDataContainer).DisplayFor(t => t);
            htmlOutput += html.DisplayFor(x => node.Data);
            //htmlOutput += (node.Data).ToString();
            htmlOutput += "</div>";
            htmlOutput += html.Tree(node.Children);
            htmlOutput += "</li>";
            return(htmlOutput);
        }
Exemple #2
0
        public static MvcHtmlString Tree <T>(this HtmlHelper <OrgNode <T> > html, OrgNode <T> root)
        {
            string htmlOutput = string.Empty;

            htmlOutput += "<div class='centered orgchart'><ul>";
            htmlOutput += html.Branch(root, true);
            htmlOutput += "</ul></div>";
            return(new MvcHtmlString(htmlOutput));
        }