// drag-and-drop to reorder nodes protected void ASPxTreeList1_CustomCallback(object sender, DevExpress.Web.ASPxTreeList.TreeListCustomCallbackEventArgs e) { ASPxTreeList tl = (ASPxTreeList)sender; if (e.Argument.StartsWith("reorder:")) { string[] arg = e.Argument.Split(':'); SwapNodes(tl.FindNodeByKeyValue(arg[1]), tl.FindNodeByKeyValue(arg[2])); tl.DataBind(); } }
protected void treelistCurrency_HtmlDataCellPrepared(object sender, TreeListHtmlDataCellEventArgs e) { try { ASPxTreeList tree = sender as ASPxTreeList; TreeListNode node = tree.FindNodeByKeyValue(e.NodeKey); NAS.DAL.Accounting.Currency.Currency currency = node.DataItem as NAS.DAL.Accounting.Currency.Currency; if (currency != null) { //Setting Description for node if (e.Column.Name == "Description" && e.Level > 1) { e.Cell.Text = String.Format("1 {0} = {1} {2}", currency.ParentCurrencyId.Name, currency.NumRequired, currency.Name); } else if (e.Column.Name == "Description" && e.Level == 1) { e.Cell.Text = String.Format("Là đơn vị cao nhất"); } if (e.Column.FieldName == "NumRequired" && e.Level == 1) { e.Cell.Text = string.Empty; } } } catch (Exception) { throw; } }
protected void treelistCurrency_CellEditorInitialize(object sender, DevExpress.Web.ASPxTreeList.TreeListColumnEditorEventArgs e) { ASPxTreeList treelistCurrency = sender as ASPxTreeList; if (e.Column.FieldName.Equals("NumRequired") && !treelistCurrency.IsNewNodeEditing) { TreeListNode node = treelistCurrency.FindNodeByKeyValue(e.NodeKey); if (node.Level == 1) { ASPxTextEdit txtEdit = (ASPxTextEdit)e.Editor; txtEdit.ReadOnly = true; } } if (e.Column.FieldName.Equals("NumRequired") && treelistCurrency.IsNewNodeEditing && treelistCurrency.NewNodeParentKey == treelistCurrency.RootNode.Key) { e.Editor.Value = 1; e.Editor.ReadOnly = true; } if (e.Column.FieldName.Equals("NumRequired") && !treelistCurrency.IsNewNodeEditing) { e.Editor.Focus(); } }
public static void InsertNode(ASPxTreeList treeList, ASPxDataInsertingEventArgs e) { XmlDataSource xmlDataXource = treeList.Page.FindControl(treeList.DataSourceID) as XmlDataSource; XmlDocument docum = xmlDataXource.GetXmlDocument(); AddNewNodeId(e.NewValues, docum); var parentNodeInTreeList = treeList.FindNodeByKeyValue(treeList.NewNodeParentKey); var parentID = parentNodeInTreeList.GetValue("Id").ToString(); XmlNode parentNode = FindNode(docum, parentID); var level = Convert.ToInt32(parentNode.Attributes["Level"].Value) + 1; XmlNode newNode = docum.CreateElement("Level" + level + "Node"); foreach (DictionaryEntry entry in e.NewValues) { newNode.Attributes.Append(GetNewAttribute(docum, entry.Key, entry.Value)); } newNode.Attributes.Append(GetNewAttribute(docum, "Level", level)); newNode.Attributes.Append(GetNewAttribute(docum, "ParentKey", parentID)); parentNode.AppendChild(newNode); RearrangeAndSaveXml(docum); }
protected void ASPxTreeList1_CustomCallback(object sender, TreeListCustomCallbackEventArgs e) { ASPxTreeList tree = sender as ASPxTreeList; TreeListNode deletingNode = tree.FindNodeByKeyValue(e.Argument); DeleteNodeAndChildren(deletingNode, tree); }
protected void grdProductUnit_HtmlDataCellPrepared(object sender, TreeListHtmlDataCellEventArgs e) { //Setting numberRequired ASPxTreeList tree = sender as ASPxTreeList; if (e.Column.FieldName == "NumRequired" && e.Level == 1) { e.Cell.Text = ""; } //Setting Description for node if (e.Column.Name == "Description") { TreeListNode node = tree.FindNodeByKeyValue(e.NodeKey); NAS.DAL.Nomenclature.Item.ItemUnit currentItem = (NAS.DAL.Nomenclature.Item.ItemUnit)node.DataItem; if (e.Level > 1) { NAS.DAL.Nomenclature.Item.ItemUnit parentItem = (NAS.DAL.Nomenclature.Item.ItemUnit)node.ParentNode.DataItem; e.Cell.Text = String.Format("1 {0} bao gồm {1} {2}", parentItem.UnitId.Name, currentItem.NumRequired, currentItem.UnitId.Name); } else { e.Cell.Text = String.Format("{0} là đơn vị tính cao nhất", currentItem.UnitId.Name); } } }
protected void ASPxTreeList1_CustomCallback(object sender, TreeListCustomCallbackEventArgs e) { ASPxTreeList treeList = (ASPxTreeList)sender; treeList.UpdateEdit(); string[] data = e.Argument.Split(new char[] { '|' }); treeList.FindNodeByKeyValue(data[0]).Focus(); for (int i = 0; i < treeList.Columns.Count; i++) { TreeListDataColumn column = (TreeListDataColumn)treeList.Columns[i]; if (column != null) { if (column.FieldName != data[1]) { column.EditCellTemplate = new MyTemplate(); } else { Session["column"] = column.FieldName; column.EditCellTemplate = null; } } } treeList.StartEdit(data[0]); }
void tree_HtmlRowPrepared(object sender, TreeListHtmlRowEventArgs e) { if (e.RowKind == TreeListRowKind.Data) { DevExpress.Web.ASPxTreeList.TreeListNode node = tree.FindNodeByKeyValue(e.NodeKey); if (!node.HasChildren) { e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='lightgray';this.style.cursor='pointer'"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor='';"); } else { e.Row.BackColor = System.Drawing.Color.Gray; e.Row.Font.Bold = true; } } }
void OnCommand(object sender, CommandEventArgs e) { Control control = sender as Control; Page page = control.Page; Label infoLabel = page.FindControl("lblInfo") as Label; ASPxTreeList treeList = page.FindControl("tree") as ASPxTreeList; TreeListNode node = treeList.FindNodeByKeyValue(e.CommandArgument.ToString()); infoLabel.Text = string.Format("Budget of <b>{0}</b> is <b>{1:C}</b>", node["Department"], node["Budget"]); }
protected void tlData_HtmlRowPrepared(object sender, TreeListHtmlRowEventArgs e) { ASPxTreeList treeList = sender as ASPxTreeList; if (e.RowKind == TreeListRowKind.Data) { TreeListNode parent = treeList.FindNodeByKeyValue(e.NodeKey).ParentNode; e.Row.Attributes.Add("nodeParent", (parent == null) ? String.Empty : parent.Key); } }
public static TreeListNode GetParentNode(this ASPxTreeList source, string childNodeKey) { if (childNodeKey == null) { return(null); } var childNode = source.FindNodeByKeyValue(childNodeKey); return(childNode != null ? childNode.ParentNode : null); }
private void ASPxTreeList_ViTri_CustomDataCallback(object sender, TreeListCustomDataCallbackEventArgs e) { string key = e.Argument.ToString(); DevExpress.Web.ASPxTreeList.TreeListNode node = ASPxTreeList_ViTri.FindNodeByKeyValue(key); if (node != null) { e.Result = Request.Url.AbsolutePath + "?key=" + key; } else { e.Result = Request.Url.AbsolutePath; } }
protected void treelstToolUnits_HtmlDataCellPrepared(object sender, TreeListHtmlDataCellEventArgs e) { ASPxTreeList tree = sender as ASPxTreeList; if (e.Column.FieldName == "NumRequired" && (e.Level == 1 || e.Level == 2)) { e.Cell.Text = "1"; } if (e.Column.FieldName == "Description" && e.Level == 2) { TreeListNode node = tree.FindNodeByKeyValue(e.NodeKey); //ViewToolUnitConstruction parentItem = (ViewToolUnitConstruction)node.ParentNode.DataItem; //ViewToolUnitConstruction currentItem = (ViewToolUnitConstruction)node.DataItem; //e.Cell.Text = String.Format("CCDC có Đơn vị tính cao nhất là {0}", currentItem.Name); } else if (e.Column.FieldName == "Description" && (e.Level != 1 && e.Level != 2)) { TreeListNode node = tree.FindNodeByKeyValue(e.NodeKey); //ViewToolUnitConstruction parentItem = (ViewToolUnitConstruction)node.ParentNode.DataItem; //ViewToolUnitConstruction currentItem = (ViewToolUnitConstruction)node.DataItem; //e.Cell.Text = String.Format("1 {0} bao gồm {1} {2}", parentItem.Name, currentItem.NumRequired, currentItem.Name); } }
public static T GetItem <T>(this ASPxTreeList source, object nodeKey) { if (nodeKey == null) { return(default(T)); } var node = source.FindNodeByKeyValue(nodeKey.ToString()); if (node == source.RootNode) { return(default(T)); } return((T)(node != null ? node.DataItem : null)); }
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 treelstMaterialUnits_CommandColumnButtonInitialize(object sender, TreeListCommandColumnButtonEventArgs e) { ASPxTreeList tree = sender as ASPxTreeList; if (e.NodeKey == null) { return; } TreeListNode node = tree.FindNodeByKeyValue(e.NodeKey); //ViewMaterialUnitConstruction currentItem = (ViewMaterialUnitConstruction)node.DataItem; if (e.NodeKey == Utility.Constant.ROOTUNITNODECODE) { e.CommandColumn.DeleteButton.Visible = false; e.CommandColumn.EditButton.Visible = false; } }
protected void treelstMaterialUnits_HtmlDataCellPrepared(object sender, TreeListHtmlDataCellEventArgs e) { //Setting numberRequired ASPxTreeList tree = sender as ASPxTreeList; if (e.Column.FieldName == "NumRequired" && e.Level == 1) { e.Cell.Text = ""; } //Setting Description for node if (e.Column.FieldName == "Description" && e.Level > 2) { TreeListNode node = tree.FindNodeByKeyValue(e.NodeKey); //ViewMaterialUnitConstruction parentItem = (ViewMaterialUnitConstruction)node.ParentNode.DataItem; //ViewMaterialUnitConstruction currentItem = (ViewMaterialUnitConstruction)node.DataItem; //e.Cell.Text = String.Format("1 {0} bao gồm {1} {2}", parentItem.Name, currentItem.NumRequired, currentItem.Name); } }
protected void ASPxTreeList1_SelectionChanged(object sender, EventArgs e) { ASPxTreeList treeList = sender as ASPxTreeList; if (treeList.SelectionCount == 1) // One node is selected within the control { LastSelectedNode = treeList.GetSelectedNodes()[0].Key; } if (treeList.SelectionCount > 1) // Applies selection to the last selected node, if two nodes are selected { TreeListNode prevSelectedNode = treeList.FindNodeByKeyValue(LastSelectedNode); if (prevSelectedNode != null) { prevSelectedNode.Selected = false; LastSelectedNode = treeList.GetSelectedNodes()[0].Key; } } }
protected void grdSitemap_HtmlRowPrepared(object sender, DevExpress.Web.ASPxTreeList.TreeListHtmlRowEventArgs e) { ASPxTreeList treeList = (ASPxTreeList)sender; ASPxCheckBox selectionCheckbox = null; foreach (TableCell cell in e.Row.Cells) { TreeListSelectionCell selectionCell = cell as TreeListSelectionCell; if (selectionCell != null) { selectionCheckbox = (ASPxCheckBox)selectionCell.Controls[0]; break; } } if (selectionCheckbox != null) { TreeListNode node = treeList.FindNodeByKeyValue(e.NodeKey); selectionCheckbox.Checked = true; } }
/////2013-09-21 ERP-580 Khoa.Truong INS END /// <summary> /// Implements IFormEditBase interface /// </summary> #region IFormEditBase Implementation #endregion //protected void grdataWarehouseCategory_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) //{ // e.Cancel = true; //} //protected void grdataWarehouseCategory_RowValidating(object sender, DevExpress.Web.Data.ASPxDataValidationEventArgs e) //{ // ASPxGridView grid = sender as ASPxGridView; // ASPxComboBox cboCode = this.grdataWarehouseCategory.FindEditRowCellTemplateControl(grdataWarehouseCategory.Columns["Code"] as GridViewDataColumn // , "cboCodeCategory") as ASPxComboBox; // string selectedCode = cboCode.SelectedItem.Value.ToString(); //} //protected void grdataWarehouseCategory_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) //{ // ASPxGridView grdToolOnCategory = sender as ASPxGridView; // ASPxComboBox cboCode = grdToolOnCategory.FindEditRowCellTemplateControl(this.grdataWarehouseCategory.Columns["Code"] as GridViewDataColumn // , "cboCodeCategory") as ASPxComboBox; // //List<WarehouseWarehouseCategoryEntity> table = CategoryEntityList; // //if (table == null) // // table = new List<WarehouseWarehouseCategoryEntity>(); // //string selectedCode = cboCode.SelectedItem.Value.ToString(); // //WarehouseWarehouseCategoryEntity category = new WarehouseWarehouseCategoryEntity(); // //if (this.Action != "new") // //{ // // category = this.toolBOL.getCategoriesOnWarehouse(selectedCode, this.toolKey); // //} // //else // //{ // // category = toolBOL.getCategoryByCode(selectedCode); // //} // //table.Add(new WarehouseWarehouseCategoryEntity( // // category.WarehouseWarehouseCategoryId, // // category.WarehouseId, // // category.WarehouseCategoryId, // // selectedCode, // // category.Name // //)); // //CategoryEntityList = table; // //this.grdataWarehouseCategory.DataSource = table; // //grdataWarehouseCategory.DataBind(); // e.Cancel = true; // grdataWarehouseCategory.CancelEdit(); //} protected void treelstToolUnits_HtmlDataCellPrepared(object sender, DevExpress.Web.ASPxTreeList.TreeListHtmlDataCellEventArgs e) { ASPxTreeList tree = sender as ASPxTreeList; TreeListNode node = tree.FindNodeByKeyValue(e.NodeKey); Inventory currentProductProductUnit = node.DataItem as Inventory; if (currentProductProductUnit != null) { //Setting Description for node if (e.Column.Name == "Description" && e.Level > 1) { e.Cell.Text = String.Format("Một {0} bao gồm {1} {2}", currentProductProductUnit.ParentInventoryId.InventoryUnitId.Name, currentProductProductUnit.NumRequired, currentProductProductUnit.InventoryUnitId.Name); } else if (e.Column.Name == "Description" && e.Level == 1) { e.Cell.Text = String.Format("Kho bao gồm {1} {0}", currentProductProductUnit.InventoryUnitId.Name, currentProductProductUnit.NumRequired); } } }
protected void ASPxTreeListDemo_HtmlRowPrepared(object sender, DevExpress.Web.ASPxTreeList.TreeListHtmlRowEventArgs e) { ASPxTreeList treeList = (ASPxTreeList)sender; WebControl selectionCheckbox = null; foreach (TableCell cell in e.Row.Cells) { TreeListSelectionCell selectionCell = cell as TreeListSelectionCell; if (selectionCell != null) { selectionCheckbox = (WebControl)selectionCell.Controls[0]; break; } } if (selectionCheckbox != null) { TreeListNode node = treeList.FindNodeByKeyValue(e.NodeKey); if (node.HasChildren) { selectionCheckbox.Enabled = false; } } }
protected void treelstToolUnits_CellEditorInitialize(object sender, TreeListColumnEditorEventArgs e) { ASPxTreeList tree = sender as ASPxTreeList; if (e.Column.FieldName == "NumRequired" && e.NodeKey != null) { TreeListNode node = tree.FindNodeByKeyValue(e.NodeKey); //ViewToolUnitConstruction dataItem = (ViewToolUnitConstruction)node.DataItem; //if (dataItem.ParentToolToolUnitId.GetHashCode() == 0) //{ // e.Editor.ClientEnabled = false; // e.Editor.Value = 1; //} } else { if (tree.NewNodeParentKey == "") { e.Editor.ClientEnabled = false; e.Editor.Value = 1; } } }
protected void tgrdAccountBalance_HtmlRowPrepared(object sender, DevExpress.Web.ASPxTreeList.TreeListHtmlRowEventArgs e) { ASPxTreeList treelist = sender as ASPxTreeList; int visibleIndex = treelist.GetVisibleNodes().IndexOf(treelist.FindNodeByKeyValue(e.NodeKey)); if (e.Level == 1) { e.Row.Font.Bold = true; } Account _account = session.GetObjectByKey <Account>(e.GetValue("AccountId")); if (_account != null) { if (_account.AccountTypeId.AccountCategoryId.AccountCategoryId == Guid.Parse("C1EC8F33-C4F6-4312-AE4A-6F8FD3A1F5DB")) { e.Row.BackColor = Color.FromArgb(211, 235, 183); } else { e.Row.BackColor = Color.FromArgb(0, 255, 255); } } }
protected void treelstMaterialUnits_CellEditorInitialize(object sender, TreeListColumnEditorEventArgs e) { ASPxTreeList tree = sender as ASPxTreeList; if (e.Column.FieldName == "NumRequired" && e.NodeKey != null) { TreeListNode node = tree.FindNodeByKeyValue(e.NodeKey); //ViewMaterialUnitConstruction dataItem = (ViewMaterialUnitConstruction)node.DataItem; //ViewMaterialUnitConstruction fhjfj = (ViewMaterialUnitConstruction)grdMaterialOnCategory.GetRow(1); //if (dataItem.ParentMaterialMaterialUnitId.GetHashCode() == 0) //{ // e.Editor.ClientEnabled = false; // e.Editor.Value = 1; //} } //else //{ // if (tree.NewNodeParentKey.GetHashCode() == 0) // { // e.Editor.ClientEnabled = false; // e.Editor.Value = 1; // } //} }
protected void treeList_Callback(object sender, TreeListCustomCallbackEventArgs e) { ASPxTreeList tree = sender as ASPxTreeList; if (e.Argument.ToString() != "" && e.Argument.Length > 1) { hiddenIdEmp.Value = e.Argument.ToString().Substring(1); string idEmp = e.Argument.ToString().Substring(1); decimal UnitPerentId = 0, UnitChildId = 0; UnitChildId = objEmployees.GetEmployees(Convert.ToInt32(idEmp)).unitid; UnitPerentId = objUnit.GetUnit(objEmployees.GetEmployees(Convert.ToInt32(idEmp)).unitid).parentid; foreach (TreeListNode nodeParent in tree.Nodes) { if (Convert.ToDecimal(nodeParent.Key.Substring(1)) == UnitPerentId) { nodeParent.Expanded = true; foreach (TreeListNode p in nodeParent.ChildNodes) { if (p.Key.Contains("u")) { if (p.Expanded) { p.Expanded = false; } if (Convert.ToDecimal(p.Key.Substring(1)) == UnitChildId) { p.Expanded = true; foreach (TreeListNode c in p.ChildNodes) { if (Convert.ToDecimal(idEmp) == Convert.ToDecimal(c.Key.Substring(1))) { c.Expanded = true; c.Focus(); } } } } } } else { if (nodeParent.Expanded) { nodeParent.Expanded = false; } TreeListNode nodeParentC2 = tree.FindNodeByKeyValue(UnitChildId.ToString()); if (nodeParentC2 != null) { nodeParentC2.Expanded = true; foreach (TreeListNode c in nodeParentC2.ChildNodes) { if (c.Expanded) { c.Expanded = false; } if (Convert.ToInt32(idEmp) == Convert.ToInt32(c.Key.Substring(1))) { c.Expanded = true; c.Focus(); } } } } } } tree.RefreshVirtualTree(); }
public static TreeListNode NewNodeParentNode(this ASPxTreeList source) { return(source.NewNodeParentKey != null?source.FindNodeByKeyValue(source.NewNodeParentKey) : null); }
static void AddHiddenNodeValues(OrderedDictionary values, object key, ASPxTreeList treeList) { TreeListNode node = treeList.FindNodeByKeyValue(key.ToString()); values["Id"] = node.GetValue("Id"); }
protected void tlData_CustomCallback(object sender, TreeListCustomCallbackEventArgs e) { TreeListNodeCollection siblingNodes; ASPxTreeList treeList = sender as ASPxTreeList; Dictionary <string, int> SortIndex = Session[treeList.UniqueID + "_Sort"] as Dictionary <string, int>; if (e.Argument == "MOVEUP" || e.Argument == "MOVEDOWN") { siblingNodes = (treeList.FocusedNode.ParentNode == null) ? treeList.Nodes : treeList.FocusedNode.ParentNode.ChildNodes; int siblingCount = siblingNodes.Count; int Index = SortIndex[treeList.FocusedNode.Key]; int NewIndex = Index; if (e.Argument == "MOVEUP") { NewIndex = (Index == 0) ? Index : Index - 1; } if (e.Argument == "MOVEDOWN") { NewIndex = (Index == (siblingCount - 1)) ? Index : Index + 1; } foreach (TreeListNode node in siblingNodes) { if (SortIndex[node.Key] == NewIndex) { SortIndex[treeList.FocusedNode.Key] = NewIndex; SortIndex[node.Key] = Index; break; } } } if (e.Argument.Contains("DRAGNODE")) { string[] swapKeys = e.Argument.Remove(0, 8).Split('|'); TreeListNode draggingNode = treeList.FindNodeByKeyValue(swapKeys[0]); TreeListNode targetNode = treeList.FindNodeByKeyValue(swapKeys[1]); if ((draggingNode != null) && (targetNode != null)) { siblingNodes = (targetNode.ParentNode == null) ? treeList.Nodes : targetNode.ParentNode.ChildNodes; int targetIndex = SortIndex[targetNode.Key]; int draggingIndex = SortIndex[draggingNode.Key]; int draggingDirection = (targetIndex < draggingIndex) ? 1 : -1; foreach (TreeListNode node in siblingNodes) { if ((SortIndex[node.Key] > Math.Min(targetIndex, draggingIndex)) && (SortIndex[node.Key] < Math.Max(targetIndex, draggingIndex))) { SortIndex[node.Key] += draggingDirection; } } SortIndex[draggingNode.Key] = targetIndex; SortIndex[targetNode.Key] = targetIndex + draggingDirection; } } treeList.DataBind(); UpdateTreeListButtons(treeList); }