/// <summary>
        /// GET api/DimArea/Get
        ///返回所有的表格数据,json或xml格式
        /// </summary>
        public JsonResult GetBySelLibId(String id = "1")
        {
            IList<TbDimArea> items = DimAreaDAO.GetByPageDataBase(0, int.MaxValue, "ILevel ASC,IParentID ASC,Id ASC", "ILibID='" + id + "'", out totalCount);//按ILevel升级,再按ParentID排序

            IList<zTreeNode> zNodes = new List<zTreeNode>();

            //写入根结点
            zTreeNode myNode = new zTreeNode();
            myNode.name = "根结点";
            myNode.open = true;

            myNode.id = 0;
            myNode.pId = -1;
            zNodes.Add(myNode);

            for (int i = 0; i < items.Count; i++)
            {
                myNode = new zTreeNode();

                myNode.name = items[i].SAreaName;
                myNode.open = false;

                myNode.id = items[i].Id;
                myNode.pId = (int)items[i].IParentID;
                myNode.tip = items[i].SAreaName;
                //if (items[i].ILevel != null && items[i].ILevel < 2) myNode.open = true;//自动扩展1,2级
                zNodes.Add(myNode);

            }

            return Json(zNodes, JsonRequestBehavior.AllowGet);
        }
示例#2
0
        /// <summary>
        /// return all tree,auto expend openLevel,seems,open  selecteid id with the parents
        /// </summary>
        /// <returns></returns>
        public JsonResult TreeWithSelected(int openLevel, int selectedID)
        {
            IList<TbDimArea> items = DimAreaDAO.GetByPageDataBase(0, int.MaxValue, "ILevel ASC,IParentID ASC,Id ASC", "1=1", out totalCount);//按ILevel升级,再按ParentID排序

            IList<zTreeNode> zNodes = new List<zTreeNode>();
            zTreeNode selectedNode=null;
             //写入根结点
            zTreeNode myNode = new zTreeNode();
            myNode.name = "根结点";
            myNode.open = true;

            myNode.id = 0;
            myNode.pId = -1;
            zNodes.Add(myNode);

            for (int i = 0; i < items.Count; i++)
            {
                myNode = new zTreeNode();

                myNode.name = items[i].SAreaCode;
                myNode.open = false;

                myNode.id = items[i].Id;
                myNode.pId = (int)items[i].IParentID;
                myNode.tip = items[i].SAreaCode;
                if (items[i].ILevel!= null && items[i].ILevel < openLevel) myNode.open = true;//自动扩展openLevel级
                zNodes.Add( myNode);

                if(selectedID==myNode.id){
                selectedNode=myNode;//temp save node
                }
            }

            if (selectedNode != null)
            {

                for(int j = zNodes.Count-1; j >=0; j--)
                {
                   if(zNodes[j].id== selectedNode.pId){
                        zNodes[j].open=true;
                        selectedNode=zNodes[j];//point the next parent;
                    }
                }
            }
            return Json(zNodes,JsonRequestBehavior.AllowGet);
        }
示例#3
0
        public JsonResult DimLibAreaTree(int libId)
        {
            IList<TbDimArea> items = DimAreaDAO.GetByPageDataBase(0, int.MaxValue, "ILevel ASC,IParentID ASC,Id ASC", "ILibID=" + libId, out totalCount);//按ILevel升级,再按ParentID排序

            IList<zTreeNode> zNodes = new List<zTreeNode>();

            //写入根结点
            zTreeNode myNode = new zTreeNode();
            myNode.name = "根结点";
            myNode.open = true;

            myNode.id = 0;
            myNode.pId = -1;
            zNodes.Add(myNode);

            for (int i = 0; i < items.Count; i++)
            {
                myNode = new zTreeNode();

                myNode.name = items[i].SAreaName;
                myNode.open = false;

                myNode.id = items[i].Id;
                myNode.pId = (int)items[i].IParentID;
                myNode.tip = items[i].SAreaName;
                zNodes.Add(myNode);

            }

            return Json(zNodes, JsonRequestBehavior.AllowGet);
        }
示例#4
0
        /// <summary>
        /// return all tree
        /// </summary>
        /// <returns></returns>
        public JsonResult TreeAll()
        {
            IList<TbSysRole> items = SysRoleDAO.GetByPageDataBase(0, int.MaxValue, "ILevel ASC,IParentID ASC,Id ASC", "1=1", out totalCount);//按ILevel升级,再按ParentID排序

            IList<zTreeNode> zNodes = new List<zTreeNode>();

            //写入根结点
            zTreeNode myNode = new zTreeNode();
            myNode.name = "根结点";
            myNode.open = true;

            myNode.id = 0;
            myNode.pId = -1;
            zNodes.Add(myNode);

            for (int i = 0; i < items.Count; i++)
            {
                myNode = new zTreeNode();

                myNode.name = items[i].SRoleName;
                myNode.open = false;

                myNode.id = items[i].Id;
                myNode.pId = (int)items[i].IParentId;
                myNode.tip = items[i].SRoleName;
                if (items[i].ILevel!= null && items[i].ILevel < 2) myNode.open = true;//自动扩展1,2级
                zNodes.Add( myNode);

            }

            return Json(zNodes,JsonRequestBehavior.AllowGet);
        }