private DataTable NavigatorBuildDataTable(object selTreeList) { ASPxTreeList tree = (ASPxTreeList)selTreeList; DataTable dt = new DataTable(); string[] fieldValues = new string[5]; List <string> fieldValuesID = new List <string>(); List <string> fieldValuesDisplayText = new List <string>(); List <string> fieldValuesOrderNum = new List <string>(); List <string> fieldValuesParentID = new List <string>(); List <string> fieldValuesPageLink = new List <string>(); dt.Columns.Add("ID"); dt.Columns.Add("DisplayText"); dt.Columns.Add("OrderNum"); dt.Columns.Add("ParentID"); dt.Columns.Add("PageLink"); IEnumerable <TreeListNode> list = tree.GetAllNodes(); foreach (TreeListNode node in list) { fieldValues[0] = node.GetValue("ID").ToString(); fieldValues[1] = node.GetValue("DisplayText").ToString(); fieldValues[2] = node.GetValue("OrderNum").ToString(); fieldValues[3] = node.GetValue("ParentID").ToString(); fieldValues[4] = node.GetValue("PageLink").ToString(); dt.Rows.Add(fieldValues); } return(dt); }
/// <summary> /// This method fills the sort index column with appropriate values /// You can avoid using it if you have a persistent column in your data source /// </summary> protected void tlData_DataBound(object sender, EventArgs e) { ASPxTreeList treeList = sender as ASPxTreeList; bool defaultNodes = (Session[treeList.UniqueID + "_Sort"] == null); ICollection <TreeListNode> allNodes = treeList.GetAllNodes(); if (defaultNodes) { Dictionary <string, int> nodeOrder = new Dictionary <string, int>(); foreach (TreeListNode node in allNodes) { string parentKey = (node.ParentNode == null) ? String.Empty : node.ParentNode.Key; int order = 0; if (nodeOrder.ContainsKey(parentKey)) { order = ++nodeOrder[parentKey]; } else { nodeOrder[parentKey] = order; } node.SetValue("SortIndex", order); } Dictionary <string, int> SortIndex = new Dictionary <string, int>(); foreach (TreeListNode node in allNodes) { SortIndex.Add(node.Key, (int)node.GetValue("SortIndex")); } Session[treeList.UniqueID + "_Sort"] = SortIndex; } else { Dictionary <string, int> SortIndex = Session[treeList.UniqueID + "_Sort"] as Dictionary <string, int>; foreach (TreeListNode node in allNodes) { node.SetValue("SortIndex", SortIndex[node.Key]); } } treeList.SortBy(treeList.Columns["SortIndex"] as TreeListDataColumn, ColumnSortOrder.Ascending); }
protected void TreeList_CustomJSProperties(object sender, DevExpress.Web.ASPxTreeList.TreeListCustomJSPropertiesEventArgs e) { ASPxTreeList tree = (ASPxTreeList)sender; e.Properties["cpSiblingKeys"] = tree.GetAllNodes().ToDictionary(n => n.Key, n => n.ParentNode.ChildNodes.OfType <TreeListNode>().Select(c => c.Key)); }