首页 > 其他 > 详细

绑定树tree 的后台方法

时间:2014-02-20 23:56:59      阅读:563      评论:0      收藏:0      [点我收藏+]
#region 获取部门列表树集合
        /// <summary>
        /// 获取部门列表树集合
        /// </summary>
        /// <returns></returns>
        public string GetOrganizationList()
        {
            System.Collections.IList orgainList = organizationibll.GetList();//获取部门方法
            IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
            timeConverter.DateTimeFormat = "yyyy‘-‘MM‘-‘dd‘ ‘HH‘:‘mm‘:‘ss";
            List<SYS_Organization> listtree = SysManager.Common.Utilities.IListHelper.IListToList<SYS_Organization>(orgainList);//将IList 转化成List
            SYS_Organization orgobj = listtree.Find(org => org.ParentId == "0");//构造顶级节点//(数据库中用的是O)
            LEFTTREE lefttree = new LEFTTREE();
            lefttree.ID = orgobj.OrganizationId;
            lefttree.TEXT = orgobj.FullName;
            lefttree.CHILDREN = new List<LEFTTREE>();
            TreeDiGui(lefttree.ID, lefttree, listtree);
            return "["+JsonConvert.SerializeObject(lefttree).Replace("TEXT", "text").Replace("ID", "id").Replace("CHILDREN", "children")+"]";
        }
        #endregion
        #region 查找树的子节点
        /// <summary>
        /// 查找树的子节点
        /// </summary>
        /// <param name="sb"></param>
        /// <param name="ParentId"></param>
        /// <returns></returns>
        public LEFTTREE TreeDiGui(string ParentId, LEFTTREE LEFTTREE, IEnumerable<SYS_Organization> ALLTREE)
        {
            //
            IEnumerable<SYS_Organization> FindTree = ALLTREE.Where(new Func<SYS_Organization, bool>(d => d.ParentId == ParentId));
            foreach (SYS_Organization item in FindTree)
            {
                LEFTTREE ChildTree = new LEFTTREE();
                ChildTree.ID = item.OrganizationId;
                ChildTree.TEXT = item.FullName;
                ChildTree.CHILDREN = new List<LEFTTREE>();
                // ChildTree.CHILDREN.Add(ChildTree);
                LEFTTREE.CHILDREN.Add(ChildTree);
                TreeDiGui(ChildTree.ID, ChildTree, ALLTREE);
            }
            return LEFTTREE;
        }
        #endregion

绑定树tree 的后台方法

原文:http://www.cnblogs.com/dullbaby/p/3557504.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!