Ejemplo n.º 1
0
 public void AddChildren(EasyTreeNode node)
 {
     if (children == null)
     {
         this.children = new List <EasyTreeNode>();
     }
     this.children.Add(node);
 }
Ejemplo n.º 2
0
        public void PaserNode(EasyTreeNode node)
        {
            List <DataRow> rows = source.AsEnumerable().Where(s => s[parentField].ToString() == node.id).ToList();

            if (rows != null && rows.Count > 0)
            {
                foreach (DataRow row in rows)
                {
                    EasyTreeNode temp = new EasyTreeNode()
                    {
                        id       = row[idField].ToString(),
                        text     = row[textField].ToString(),
                        parentId = row[parentField].ToString(),
                        tag      = (tagField != null && tagField.Length > 0) ? row[tagField].ToString() : ""
                    };
                    PaserNode(temp);
                    node.AddChildren(temp);
                }
            }
            else
            {
                return;
            }
        }
Ejemplo n.º 3
0
        public IList <EasyTreeNode> paserTree()
        {
            IList <EasyTreeNode> list = new List <EasyTreeNode>();

            if (this.source != null && this.source.Rows.Count > 0)
            {
                foreach (DataRow row in source.Rows)
                {
                    if (row[parentField] == DBNull.Value || row[parentField].ToString() == null || row[parentField].ToString().Length == 0 || row[parentField].ToString() == "0")
                    {
                        EasyTreeNode node = new EasyTreeNode()
                        {
                            id       = row[idField].ToString(),
                            text     = row[textField].ToString(),
                            parentId = "",
                            tag      = (tagField != null && tagField.Length > 0) ? row[tagField].ToString() : ""
                        };
                        PaserNode(node);
                        list.Add(node);
                    }
                }
            }
            return(list);
        }