private TreeDataViewModel[] initRoleValTree(IQueryable <SystemMenu> menus, IQueryable <SystemMenu> parents, IQueryable <SystemRoleValue> rolevalues) { List <TreeDataViewModel> child = new List <TreeDataViewModel>(); var parentsnav = parents.OrderBy(o => o.Sort); foreach (var p in parentsnav) { TreeDataViewModel roleval = new TreeDataViewModel(); roleval.id = p.ID; roleval.title = p.MenuName; var parents2 = menus.Where(n => n.ParentID == p.ID); if (parents2.Count() > 0) { roleval.spread = true; roleval.children = initRoleValTree(menus, parents2, rolevalues); } else { if (rolevalues.Where(q => q.MenuId == p.ID).Count() > 0) { roleval.@checked = true; } roleval.children = null; } child.Add(roleval); } return(child.ToArray()); }
private List <TreeDataViewModel> GettreeData(List <SystemMenu> menus, string parentId) { List <TreeDataViewModel> res = new List <TreeDataViewModel>(); var childs = menus.Where(p => p.ParentID == parentId); foreach (var c in childs) { TreeDataViewModel tree = new TreeDataViewModel(); tree.title = c.MenuName; tree.id = c.ID; tree.spread = true; //tree.@checked = true; if (c.IsShow.Value) { tree.disabled = false; } else { tree.disabled = true; } tree.children = GettreeData(menus, c.ID).ToArray(); res.Add(tree); } return(res); }
public ActionResult GetAllRoleValues() { var result = ResModelFactory.ResDefaultData <TreeDataViewModel>(); //获取所有菜单 SystemMenuService services = new SystemMenuService(); var menus = services.GetEntitys(p => true).ToList(); //权限树形结构 var treedata = new List <TreeDataViewModel>(); // //找出父菜单 var parents = menus.Where(p => string.IsNullOrEmpty(p.ParentID)); foreach (var par in parents) { var tree = new TreeDataViewModel(); tree.title = par.MenuName; tree.id = par.ID; tree.spread = true; tree.@checked = true; if (par.IsShow.Value) { tree.disabled = false; } else { tree.disabled = true; } var childs = menus.Where(p => p.ParentID == p.ID); tree.children = GettreeData(menus, par.ID).ToArray(); treedata.Add(tree); } result.data = treedata.ToArray(); return(Json(result, JsonRequestBehavior.AllowGet)); }
public static string GetOnePath(TreeDataViewModel node) { string xPath = ""; if (node.TreeData.Tag.ToString() != "") { xPath = ".//" + node.TreeData.Tag; } return(xPath); }
public static void init() { TreeDataViewModel vm = new TreeDataViewModel(); GridDataViewBinder binder = new GridDataViewBinder(); List <Column> columns = new List <Column>( new Column( ColumnProperties.Id, "status", ColumnProperties.Name, "Status", ColumnProperties.Field, "status", ColumnProperties.Width, 70, ColumnProperties.MinWidth, 50, ColumnProperties.CssClass, "cell-title", ColumnProperties.Sortable, true ), new Column( ColumnProperties.Id, "project", ColumnProperties.Name, "Project", ColumnProperties.Field, "project", ColumnProperties.Width, 70, ColumnProperties.MinWidth, 50, ColumnProperties.CssClass, "cell-title", ColumnProperties.Sortable, true, ColumnProperties.Editor, XrmTextEditor.TextEditor), new Column( ColumnProperties.Id, "date", ColumnProperties.Name, "Date", ColumnProperties.Field, "date", ColumnProperties.Width, 70, ColumnProperties.Sortable, true ), new Column( ColumnProperties.Id, "employee", ColumnProperties.Name, "Employee", ColumnProperties.Field, "employee", ColumnProperties.Width, 80, ColumnProperties.Sortable, true ), new Column( ColumnProperties.Id, "duration", ColumnProperties.Name, "Duration", ColumnProperties.Field, "duration", ColumnProperties.MinWidth, 60, ColumnProperties.Sortable, true) ); vm.Items.OnGetItemMetaData += Items_OnGetItemMetaData; Grid grid = binder.DataBindXrmGrid(vm.Items, columns, "projectsGrid", null, true, false); grid.RegisterPlugin(new GroupGridRowPlugin()); // Data Bind ViewBase.RegisterViewModel(vm); }
public ActionResult GetRoleValues(string roleId) { //var result = ResModelFactory.ResDefaultData<SystemRoleValueViewModel>(); //角色信息 SystemRoleService service = new SystemRoleService(); SystemRole role = service.GetEntitys(p => p.ID == roleId).FirstOrDefault(); //角色权限信息 SystemRoleValueService rvalservice = new SystemRoleValueService(); IQueryable <SystemRoleValue> rolevalues = rvalservice.GetEntitys(p => p.RoleId == roleId); //所有系统导航信息 IQueryable <SystemMenu> navigations = new SystemMenuService().GetEntitys(p => true); RoleAndRloeValues model = new RoleAndRloeValues(); model.Id = role.ID; model.RoleName = role.RoleName; model.Description = role.Description; var parentsnav = navigations.Where(p => string.IsNullOrEmpty(p.ParentID)).OrderBy(o => o.Sort); List <TreeDataViewModel> tree = new List <TreeDataViewModel>(); foreach (var p in parentsnav) { //如果有菜单权限 选中并展开 TreeDataViewModel roleval = new TreeDataViewModel(); roleval.id = p.ID; roleval.title = p.MenuName; var parents = navigations.Where(n => n.ParentID == p.ID); if (parents.Count() > 0) { roleval.spread = true; roleval.children = initRoleValTree(navigations, parents, rolevalues); } else { if (rolevalues.Where(q => q.MenuId == p.ID).Count() > 0) { roleval.@checked = true; } roleval.children = null; } tree.Add(roleval); } model.TreeData = tree; return(View("AddRole", model)); }
public static string GetAllPath(TreeDataViewModel node) { string xPath = ""; while (node.Parent != null) { if (node.TreeData.Tag.ToString() != "") { xPath = "//" + node.TreeData.Tag + xPath; } node = node.Parent; } return(xPath); }