Example #1
0
        public object GetzTreeData(int templateId, int templeteType)
        {
            zTreeNode root = new zTreeNode();

            root.name          = "栏目列表";
            root.open          = true;
            root.templateId    = templateId;
            SqlWhereList where = new SqlWhereList();
            where.Add("ParentID", "0");
            if (templeteType == 2)
            {
                where.Add("TypeId", 1);
            }
            GetzTree(where, root, templateId, templeteType);
            return(new JsonResult(root.children));
        }
Example #2
0
        private void GetzTree(SqlWhereList where, zTreeNode root, int templateId, int templeteType)
        {
            List <Channel> list = channelBLL.GetAll(where);
            zTreeNode      node = null;

            root.children = new List <zTreeNode>();
            foreach (Channel item in list)
            {
                node = new zTreeNode();
                DataTable dt = templateDetailBLL.GetTemplateDetailChecked(templateId);
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i]["ChannelId"].Equals(item.ChannelId) && templeteType == 2)
                    {
                        node.@checked    = true;
                        node.chkDisabled = true;//设为禁用
                    }
                }
                node.id   = item.ChannelId;
                node.name = item.ChannelName;
                node.pId  = item.ParentId;
                node.open = true;
                TemplateDetail _TemplateDetail = getIsExistTemplatedetail(templateId, node.id);
                if (_TemplateDetail == null)
                {
                    node.@checked = false;
                }
                else
                {
                    node.@checked = true;
                }
                node.attributes = new zTreeNodeCustAttr(node.id);
                SqlWhereList wherelist = new SqlWhereList();
                wherelist.Add("ParentID", node.id);
                if (templeteType == 2)
                {
                    wherelist.Add("TypeId", 1);
                }
                GetzTree(wherelist, node, templateId, templeteType);
                root.children.Add(node);
            }
        }
Example #3
0
        /// <summary>
        /// 栏目树
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> Tree()
        {
            List <zTreeNode> nodes;
            var categories = await _categoryService.FindTreeAsync(null);

            if (categories != null)
            {
                nodes = new List <zTreeNode>(categories.Count());
                foreach (var category in categories)
                {
                    var node = new zTreeNode()
                    {
                        id = category.CategoryId, pId = category.ParentId, name = category.Name, url = Url.Action("Modify", "Category", new { id = category.CategoryId })
                    };
                    switch (category.Type)
                    {
                    case CategoryType.General:
                        node.iconSkin  = "fa fa-folder";
                        node.iconOpen  = "fa fa-folder-open";
                        node.iconClose = "fa fa-folder";
                        break;

                    case CategoryType.Page:
                        node.iconSkin = "fa fa-file";
                        break;

                    case CategoryType.Link:
                        node.iconSkin = "fa fa-link";
                        break;
                    }
                    nodes.Add(node);
                }
            }
            else
            {
                nodes = new List <zTreeNode>();
            }
            return(Json(nodes));
        }