/// <summary> /// 获取根菜单Json /// </summary> private string GetRoot(int deptId) { //根结点 var root = AllDepts.FirstOrDefault(p => p.ID == deptId); if (root == null) { return(null); } var jObject = new JObject( new JProperty("title", root.Name), new JProperty("tooltip", root.ID.ToString()), new JProperty("isFolder", true), new JProperty("isLazy", false), new JProperty("activate", true), new JProperty("hideCheckbox", true), //根菜单隐藏勾选框 new JProperty("addClass", "menuTreeRoot"), new JProperty("expand", true), //展开 new JProperty("key", root.ID), new JProperty("nodeType", "Dept") ); var deptTypes = typeof(SysDeptType).GetValueDescriptionCollection(); jObject.Add("children", new JArray( deptTypes.Select(ParseDeptTypeJObject) )); return(jObject.ToString()); }
/// <summary> /// 获取根菜单Json /// </summary> private string GetRoot(int year) { //根结点 var root = AllDepts.FirstOrDefault(p => p.ID == SysConsts.RootDeptID); if (root == null) { return(null); } var jObject = new JObject( new JProperty("title", root.Name), new JProperty("tooltip", root.ID.ToString()), new JProperty("isFolder", true), new JProperty("isLazy", false), new JProperty("activate", true), new JProperty("hideCheckbox", true), //根菜单隐藏勾选框 new JProperty("addClass", "menuTreeRoot"), new JProperty("expand", true), //展开 new JProperty("key", root.ID), new JProperty("nodeType", "Dept") ); var deptTypes = typeof(SysDeptType).GetValueDescriptionCollection(); jObject.Add("children", new JArray( deptTypes.Select(d => ParseDeptTypeJObject(d, year)) )); //已展开的结点列表 if (_expandedKeyList != null && _expandedKeyList.Length > 0) { _expandedKeys = _expandedKeyList.Split(',').ToList(); if (_expandedKeys.Count > 0) { //去除根结点 _expandedKeys.Remove(root.ID.ToString()); InitPersistKey(jObject, year); } } return(jObject.ToString()); }