예제 #1
0
 /// <summary>
 /// Populates the sub level.
 /// </summary>
 /// <param name="parentid">The parentid.</param>
 /// <param name="parentNode">The parent node.</param>
 private void PopulateSubLevel(int parentid, JsTreeNode parentNode)
 {
     PopulateNodes(CategoryManager.GetChildCategoriesByCategoryId(parentid), parentNode.children);
 }
예제 #2
0
        /// <summary>
        /// Populates the nodes.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <param name="nodes">The nodes.</param>
        private void PopulateNodes(List<Category> list, List<JsTreeNode> nodes)
        {
            foreach (Category c in list)
            {
                JsTreeNode cnode = new JsTreeNode();
                cnode.attr = new Attributes();
                cnode.attr.id = Convert.ToString(c.Id);
                cnode.attr.rel = "cat" + Convert.ToString(c.Id);
                cnode.data = new Data();
                cnode.data.title = Convert.ToString(c.Name);
                cnode.data.icon = "../../images/plugin.gif";
                //cnode.attributes.mdata = "{ draggable : true, max_children : 100, max_depth : 100 }";

                nodes.Add(cnode);

                if (c.ChildCount > 0)
                {

                    PopulateSubLevel(c.Id, cnode);
                }
            }
        }
예제 #3
0
        private static List<JsTreeNode> PopulateChildNodes(Category parent, List<Category> all)
        {
            var tree = new List<JsTreeNode>();

            foreach (var pCat in all.FindAll(p => p.ParentCategoryId == parent.Id))
            {
                var pNode = new JsTreeNode { attr = new Attributes() };
                pNode.attr.id = Convert.ToString(pCat.Id);
                pNode.attr.rel = "cat" + Convert.ToString(pCat.Id);
                pNode.data = new Data { title = Convert.ToString(pCat.Name), icon = "../../images/plugin.gif" };
                tree.Add(pNode);

                if (pCat.ChildCount > 0)
                {
                    pNode.children = PopulateChildNodes(pCat, all);
                }
            }

            return tree;
        }
예제 #4
0
        /// <summary>
        /// Populates the nodes.
        /// </summary>
        /// <param name="list">The list.</param>
        /// <param name="nodes">The nodes.</param>
        private void PopulateNodes(IEnumerable<Category> list, ICollection<JsTreeNode> nodes)
        {
            foreach (var c in list)
            {
                var cnode = new JsTreeNode
                                {
                                    attr =
                                        new Attributes
                                            {id = Convert.ToString(c.Id), rel = "cat" + Convert.ToString(c.Id)},
                                    data = new Data {title = Convert.ToString(c.Name), icon = "../../images/plugin.gif"}
                                };
                //cnode.attributes.mdata = "{ draggable : true, max_children : 100, max_depth : 100 }";

                nodes.Add(cnode);

                if (c.ChildCount > 0)
                {
                    PopulateSubLevel(c.Id, cnode);
                }
            }
        }
예제 #5
0
        public string GetCategories(string projectId)
        {
            if (string.IsNullOrEmpty(projectId)) throw new ArgumentNullException("projectId");

            int pid;

            if (int.TryParse(projectId, out pid))
            {
                var allCategories = CategoryManager.GetByProjectId(pid);

                var parentCategories = allCategories.FindAll(p => p.ParentCategoryId == 0);

                var tree = new List<JsTreeNode>();

                foreach (var pCat in parentCategories)
                {
                    var pNode = new JsTreeNode {attr = new Attributes()};
                    pNode.attr.id = Convert.ToString(pCat.Id);
                    pNode.attr.rel = "cat" + Convert.ToString(pCat.Id);
                    pNode.data = new Data {title = Convert.ToString(pCat.Name), icon = "../../../images/plugin.gif"};
                    tree.Add(pNode);

                    if (pCat.ChildCount > 0)
                    {
                        pNode.children = PopulateChildNodes(pCat, allCategories);
                    }
                }

                return new JavaScriptSerializer().Serialize(tree);
            }

            return string.Empty;
        }