private void TreeListDepartmentReceived_Load(object sender, EventArgs e) { if (isFirstLoad && View.ObjectSpace.Owner is DetailView && treeList != null) { treeList.Width = new Unit(90, UnitType.Percentage);; treeList.Height = new Unit(100, UnitType.Percentage); treeList.Settings.ScrollableHeight = 350; treeList.Settings.VerticalScrollBarMode = ScrollBarMode.Visible; treeList.SettingsPager.Visible = false; //Expand rồi collapse đảm bảo mọi node được load ở server side hạn chế load ở client side treeList.ExpandAll(); treeList.CollapseAll(); treeList.SettingsPager.Summary.Visible = false; treeList.SettingsPager.PageSize = 500; treeList.Settings.VerticalScrollBarMode = ScrollBarMode.Visible; /// Turn off this shit before select node //2. Selected/chọn những Department/phòng tương ứng DetailView dvOwner = View.ObjectSpace.Owner as DetailView; if (dvOwner != null && dvOwner.CurrentObject != null && dvOwner.CurrentObject is Document) { Document curDoc = dvOwner.CurrentObject as Document; if ((curDoc.EmployeeReceiveds.Count > 0)) { ///((ASPxTreeList)sender).ExpandAll(); //New_Object => không expaned all // Check những phòng ban có trong list treeList.SettingsBehavior.ProcessSelectionChangedOnServer = false; foreach (Employee emp in curDoc.EmployeeReceiveds.Where(emp => emp != null)) { var node = treeList.FindNodeByKeyValue(emp.Oid.ToString()); if (node != null) { node.Selected = true; if (node.ParentNode != null) { node.ParentNode.Expanded = true; } } } treeList.SettingsBehavior.ProcessSelectionChangedOnServer = true; } } isFirstLoad = false; //Done turn it on again } }
protected void LinkButton_Collapse_Click(object sender, EventArgs e) { ASPxTreeList_ViTri.CollapseAll(); }