Ejemplo n.º 1
0
        private zNode getZNode(Node <T> node, INodeBinder binder)
        {
            zNode x = new zNode();

            String name = binder.GetName(node.getNode());

            if (strUtil.IsNullOrEmpty(name))
            {
                name = node.getNode().Name;
            }

            x.name   = name;
            x.url    = binder.GetUrl(node.getNode());
            x.open   = binder.IsOpen(node.getNode());
            x.target = binder.GetTarget(node.getNode());

            if (node.getChildren().Count > 0)
            {
                foreach (Node <T> sub in node.getChildren())
                {
                    zNode subZ = getZNode(sub, binder);
                    x.AddSub(subZ);
                }
            }

            return(x);
        }
Ejemplo n.º 2
0
        public List <zNode> GetZNodeList(INodeBinder binder)
        {
            List <zNode> results = new List <zNode>();

            List <Node <T> > list = this.FindAllOrdered();

            for (int i = 0; i < list.Count; i++)
            {
                Node <T> node = list[i];
                if (node.getParent() != null)
                {
                    continue;
                }
                results.Add(getZNode(node, binder));
            }

            return(results);
        }
Ejemplo n.º 3
0
Archivo: Tree.cs Proyecto: g82tt/xcore
        /// <summary>
        /// 获取树状结构的 html
        /// </summary>
        /// <param name="treeId"></param>
        /// <param name="showChildren"></param>
        /// <param name="binder"></param>
        /// <param name="currentNodeId"></param>
        /// <returns></returns>
        public String RenderList(String treeId, Boolean showChildren, INodeBinder binder, int currentNodeId)
        {
            List <Node <T> > list = this.FindAllOrdered();

            StringBuilder builder = new StringBuilder();
            int           indent  = 0;

            for (int i = 0; i < list.Count; i++)
            {
                Node <T> node = list[i];

                // 是否添加 ul 以及是否隐藏
                if (i == 0)
                {
                    builder.Append("<ul class=\"wTree\" id=\"");
                    builder.Append(treeId);
                    builder.Append("\">");
                    indent++;
                }
                else if (node.indent())
                {
                    String displayCls = getDisplayCls(showChildren, currentNodeId, node.getNode().Id);

                    builder.Append("<ul");
                    builder.Append(displayCls);
                    builder.Append(">");
                    indent++;
                }
                else if (node.outdent())
                {
                    int outdentCount = node.getOutdentCount();
                    for (int x = 0; x < outdentCount; x++)
                    {
                        builder.Append("</ul>");
                        indent--;
                    }
                }

                // li 的 class
                builder.Append("<li");
                String cls = getListClass(showChildren, currentNodeId, node);
                if (strUtil.HasText(cls))
                {
                    builder.Append(" class=\"");
                    builder.Append(cls);
                    builder.Append("\"");
                }
                builder.Append(">");

                String item = (binder == null ? node.getNode().Name : binder.Bind(node.getNode()));
                builder.Append(item);
                builder.Append("</li>");
            }

            for (int y = 0; y < indent; y++)
            {
                builder.Append("</ul>");
            }

            return(builder.ToString());
        }