private void LoadDonVi(Ext.Net.TreePanel TreeCoCauToChuc, int currentUserID) { //List<DM_DONVI> dvList = new UserController().GetDonViByUserID(currentUserID); List <DM_DONVI> dvList = new DM_DONVIController().GetByParentID("0"); Ext.Net.TreeNode root = new Ext.Net.TreeNode(); foreach (DM_DONVI dv in dvList) { Ext.Net.TreeNode node = new Ext.Net.TreeNode(dv.TEN_DONVI); node.Icon = Ext.Net.Icon.House; root.Nodes.Add(node); node.Expanded = true; node.NodeID = dv.MA_DONVI; if ((!departmentList.Contains("," + dv.MA_DONVI + ",") && !string.IsNullOrEmpty(departmentList)) || string.IsNullOrEmpty(departmentList)) { node.Disabled = true; } LoadChildDepartment(dv.MA_DONVI, node); if (!string.IsNullOrEmpty(script)) { node.Listeners.Click.Handler = script.Replace(nodeID, node.NodeID).Replace(noteText, node.Text); } } TreeCoCauToChuc.Root.Clear(); TreeCoCauToChuc.Root.Add(root); }
public string GetNodes(string node) { TreeNodeCollection nodes = new TreeNodeCollection(false); string prefix = DateTime.Now.Second + "_"; for (int i = 0; i < 10; i++) { Ext.Net.TreeNode newNode = new Ext.Net.TreeNode(); newNode.NodeID = i.ToString(); newNode.Text = prefix + i; newNode.Leaf = true; nodes.Add(newNode); } return(nodes.ToJson()); }
/// <summary> /// /// </summary> /// <param name="TreeCoCauToChuc"></param> /// <param name="currentUser"></param> private void LoadDepartment(Ext.Net.TreePanel TreeCoCauToChuc, UserModel currentUser) { var rootDepartment = currentUser.RootDepartment; var root = new Ext.Net.TreeNode(); var node = new Ext.Net.TreeNode { NodeID = rootDepartment.Id.ToString(), Text = rootDepartment.Name, Icon = Ext.Net.Icon.House, Expanded = true }; root.Nodes.Add(node); LoadChildDepartment(rootDepartment.Id, node, currentUser); if (!string.IsNullOrEmpty(script)) { node.Listeners.Click.Handler = script.Replace(nodeID, node.NodeID).Replace(noteText, node.Text); } TreeCoCauToChuc.Root.Clear(); TreeCoCauToChuc.Root.Add(root); }
/// <summary> /// /// </summary> /// <param name="parentId"></param> /// <param name="parentNode"></param> /// <param name="currentUser"></param> private void LoadChildDepartment(int parentId, Ext.Net.TreeNode parentNode, UserModel currentUser) { var lstDepartments = currentUser.Departments.Where(d => d.ParentId == parentId).ToList(); foreach (var d in lstDepartments) { var node = new Ext.Net.TreeNode { NodeID = d.Id.ToString(), Text = d.Name, Icon = Ext.Net.Icon.Folder, Expanded = true }; parentNode.Nodes.Add(node); if (!string.IsNullOrEmpty(script)) { node.Listeners.Click.Handler = script.Replace(nodeID, node.NodeID).Replace(noteText, node.Text); } LoadChildDepartment(d.Id, node, currentUser); } }
protected void BindClassView(ITreeProvider provider, Guid parentID, Ext.Net.TreeNode parentNode, Guid selectedID) { List<ITreeNode> list = new List<ITreeNode>(); if (!parentID.Equals(Guid.Empty) && parentNode == null) { ITreeNode entity = provider.GetTreeNode(parentID); if (entity == null) return; list.Add(entity); } else { list = provider.GetList(parentID, User.ID, Roles); //List<ITreeNode> list = provider.GetList(parentID); } foreach (ITreeNode item in list) { Ext.Net.TreeNode treeNode; treeNode = new Ext.Net.TreeNode(item.ID.ToString(), item.Name, Ext.Net.Icon.Folder); treeNode.Cls = "TreeNode-Default"; if (parentNode != null) parentNode.Nodes.Add(treeNode); else (ClassView.Root[0] as Ext.Net.TreeNode).Nodes.Add(treeNode); if (item.ID == selectedID) { //this.selectedNodeID = this.RequestClassificationTreeID; //this.selectedNodeText = item.Name; ClassView.SelectNode(treeNode.NodeID); Ext.Net.TreeNodeBase tmpParent = treeNode.ParentNode; while (tmpParent != null) { tmpParent.Expanded = true; tmpParent = tmpParent.ParentNode; } //ClassView.SelectNode(treeNode.NodeID); //ClassView.ExpandChildNodes(treeNode.NodeID); } this.BindClassView(provider, item.ID, treeNode, selectedID); } }
private void LoadChildDepartment(string maDonVi, Ext.Net.TreeNode DvNode) { List <DonViInfo> childList = new DM_DONVIController().GetEntityByParentID(maDonVi); foreach (DonViInfo dv in childList) { Ext.Net.TreeNode node = new Ext.Net.TreeNode(dv.TenDonVi); node.Icon = Ext.Net.Icon.Folder; DvNode.Nodes.Add(node); node.Expanded = true; node.NodeID = dv.MaDonVi; if ((!departmentList.Contains("," + dv.MaDonVi + ",") && !string.IsNullOrEmpty(departmentList)) || string.IsNullOrEmpty(departmentList)) { node.Disabled = true; } if (!string.IsNullOrEmpty(script)) { node.Listeners.Click.Handler = script.Replace(nodeID, node.NodeID).Replace(noteText, node.Text); } LoadChildDepartment(dv.MaDonVi, node); } }
/*public void BindClassificationView(ITreeProvider provider, Guid parentID, TreeNode parentNode, Guid selectedID) { List<ITreeNode> list = new List<ITreeNode>(); if (!parentID.Equals(Guid.Empty) && parentNode == null) { ITreeNode entity = provider.GetTreeNode(parentID); if (entity == null) return; list.Add(entity); } else { list = provider.GetList(parentID, User.ID, Roles); //List<ITreeNode> list = provider.GetList(parentID); } foreach (ITreeNode item in list) { Basic.ColoredTreeNode node; switch (item.Section) { case TreeNodeSection.Custom: node = new Basic.ColoredTreeNode(item.Name, String.Format("cust-{0}", item.ID)); node.Color = case TreeNodeSection.Default: new Basic.ColoredTreeNode(item.Name, item.ID.ToString()); } = new Basic.ColoredTreeNode(item.Name, item.ID.ToString()); node.Color = item.Color; if (item.ID == selectedID) node.Select(); node.NavigateUrl = string.Format("Grid.aspx?cid={0}&pid={1}", node.Value, this.ClassificationTopNodeID); if (parentNode != null) parentNode.ChildNodes.Add(node); else ClassificationView.Nodes.Add(node); this.BindClassificationView(provider, item.ID, node, selectedID); } }*/ public void BindClassView(ITreeProvider provider, Guid parentID, Ext.Net.TreeNode parentNode, Guid selectedID) { List<ITreeNode> list = new List<ITreeNode>(); if (!parentID.Equals(Guid.Empty) && parentNode == null) { ITreeNode entity = provider.GetTreeNode(parentID); if (entity == null) return; list.Add(entity); } else { list = provider.GetList(parentID, User.ID, Roles); //List<ITreeNode> list = provider.GetList(parentID); } foreach (ITreeNode item in list) { Ext.Net.TreeNode treeNode; if (item.ID.Equals(new Guid("00497ABC-7ADB-11E0-AD88-63F04724019B"))) { // hack for "Wares" treeNode = new Ext.Net.TreeNode(String.Format("ware-{0}", item.ID), item.Name, Ext.Net.Icon.Folder); treeNode.Cls = "TreeNode-Wares"; treeNode.Href = String.Format("/Technology/ListWares.aspx"); } else { switch (item.Section) { case TreeNodeSection.Custom: treeNode = new Ext.Net.TreeNode(String.Format("cust-{0}", item.ID), item.Name, Ext.Net.Icon.Folder); treeNode.Cls = "TreeNode-Custom"; break; case TreeNodeSection.Dictionary: treeNode = new Ext.Net.TreeNode(String.Format("dict-{0}", item.ID), item.Name, Ext.Net.Icon.Folder); treeNode.Cls = "TreeNode-Dictionary"; break; default: treeNode = new Ext.Net.TreeNode(String.Format("dflt-{0}", item.ID), item.Name, Ext.Net.Icon.Folder); treeNode.Cls = "TreeNode-Default"; break; } treeNode.Href = String.Format("/Grid.aspx?cid={0}", item.ID); } if (parentNode != null) parentNode.Nodes.Add(treeNode); else (ClassView.Root[0] as Ext.Net.TreeNode).Nodes.Add(treeNode); if (item.ID == this.RequestClassificationTreeID) { this.selectedNodeID = this.RequestClassificationTreeID; this.selectedNodeText = item.Name; ClassView.SelectNode(treeNode.NodeID); Ext.Net.TreeNodeBase tmpParent = treeNode.ParentNode; while (tmpParent != null) { tmpParent.Expanded = true; tmpParent = tmpParent.ParentNode; } //ClassView.SelectNode(treeNode.NodeID); //ClassView.ExpandChildNodes(treeNode.NodeID); } this.BindClassView(provider, item.ID, treeNode, selectedID); } }
private void BindGrid() { DataSet data = null; ConfigurationTreeProvider provider = null; List<GridColumn> columns = new List<GridColumn>(); try { provider = new ConfigurationTreeProvider(); if (provider != null) { Aspect.Domain.Product prod = provider.GetProduct(this.ProductID); if (prod == null) return; this.Title = HeaderLiteral.Text = string.Format(HeaderLiteral.Text, prod.PublicName, prod.Version == null ? string.Empty : prod.Version.ToString()); HeaderDateLiteral.Text = string.Format(HeaderDateLiteral.Text, DateTime.Now.ToShortDateString(), DateTime.Now.ToLongTimeString()); //Response.Write(provider.getQuery(new Guid(node.Value), this.User.ID, this.OrderExpression, this.SearchConditions)); //return; data = provider.GetList(this.RequestClassificationTreeID, this.ProductID, this.User.ID, this.SearchConditions); if (ShowSelected && !String.IsNullOrEmpty(SelectedProductsHidden.Value)) { string[] ids = SelectedProductsHidden.Value.Split(',').Select(s => string.Format("CONVERT('{0}','System.Guid')", s)).ToArray(); data.Tables[0].DefaultView.RowFilter = string.Format("ID in ({0})", string.Join(",", ids)); } columns = provider.GetGridColumns(this.User.ID, this.RequestClassificationTreeID, FieldPlaceHolder.Grid); } } finally { if (provider != null) provider.Dispose(); } if (data != null && data.Tables.Count > 0) { //ProductGrid.DataSource = data.Tables[0].DefaultView; //ProductGrid.DataBind(); Stack<Ext.Net.TreeNodeCollection> stackRoots = new Stack<Ext.Net.TreeNodeCollection>(); Ext.Net.TreeNodeCollection currentRoot = (ProductTree.Root.First() as Ext.Net.TreeNode).Nodes; int? prevLevel = null, curLevel = null; foreach (DataRow row in data.Tables[0].Rows) { curLevel = Convert.ToInt32(row["Level"]); if (!prevLevel.HasValue) prevLevel = curLevel; Ext.Net.TreeNode node = new Ext.Net.TreeNode(); node.Checked = Ext.Net.ThreeStateBool.False; foreach(GridColumn column in columns) { node.CustomAttributes.Add(new Ext.Net.ConfigItem(column.DataItem.Replace('.', '_'), row[column.DataItem].ToString(), Ext.Net.ParameterMode.Value)); } node.CustomAttributes.Add(new Ext.Net.ConfigItem("ProductID", row["ID"].ToString(), Ext.Net.ParameterMode.Value)); if (curLevel > prevLevel) { stackRoots.Push(currentRoot); currentRoot = (currentRoot.Last() as Ext.Net.TreeNode).Nodes; } if (curLevel < prevLevel) { currentRoot = stackRoots.Pop(); } currentRoot.Add(node); prevLevel = curLevel; } if (data.Tables[0].Rows.Count > 0) { string function = String.Format("Ext.namespace('App'); App.cid = '{0}'; ", this.RequestClassificationTreeID); ResourceManager1.AddAfterClientInitScript(function); } this.AppendGridHeader(columns); } }