private Accordion InitAccordionMenu() { Accordion accordionMenu = new Accordion(); accordionMenu.ID = "accordionMenu"; accordionMenu.EnableFill = true; accordionMenu.ShowBorder = false; accordionMenu.ShowHeader = false; Region2.Items.Add(accordionMenu); XmlDocument xmlDoc = XmlDataSource1.GetXmlDocument(); XmlNodeList xmlNodes = xmlDoc.SelectNodes("/Tree/TreeNode"); foreach (XmlNode xmlNode in xmlNodes) { if (xmlNode.HasChildNodes) { AccordionPane accordionPane = new AccordionPane(); accordionPane.Title = xmlNode.Attributes["Text"].Value; accordionPane.Layout = Layout.Fit; accordionPane.ShowBorder = false; accordionPane.BodyPadding = "2px 0 0 0"; accordionMenu.Items.Add(accordionPane); Tree innerTree = new Tree(); innerTree.EnableArrows = true; innerTree.ShowBorder = false; innerTree.ShowHeader = false; innerTree.EnableIcons = false; innerTree.AutoScroll = true; accordionPane.Items.Add(innerTree); XmlDocument innerXmlDoc = new XmlDocument(); innerXmlDoc.LoadXml(String.Format("<?xml version=\"1.0\" encoding=\"utf-8\" ?><Tree>{0}</Tree>", xmlNode.InnerXml)); // 绑定AccordionPane内部的树控件 innerTree.DataSource = innerXmlDoc; innerTree.DataBind(); // 重新设置每个节点的图标 ResolveTreeNode(innerTree.Nodes); } } return accordionMenu; }
public void InitTree(ExtAspNet.Tree tree, DataTable data) { tree.Nodes.Clear(); if (data != null && data.Rows.Count != 0) { foreach (DataRow dr in data.Rows) { if (dr["PARENT_ID"].ToString() == string.Empty) { ExtAspNet.TreeNode node = new ExtAspNet.TreeNode(); node.NodeID = dr["DEPT_ID"].ToString(); node.Text = dr["DEPT_NAME"].ToString(); //node.IconUrl = "~/Icons/group.png"; node.Expanded = true; node.EnablePostBack = true; node.EnableCheckBox = true; CreateTree(dr["DEPT_ID"].ToString(), node, data); tree.Nodes.Add(node); } } } }
/// <summary> /// 绑定tree /// </summary> /// <param name="tree"></param> /// <param name="dtColumn"></param> /// <param name="dtFun">勾选的</param> public void ExeBindColumn(ExtAspNet.Tree tree, System.Data.DataTable dtColumn, DataTable dtFun) { tree.Nodes.Clear(); //ExtAspNet.TreeNode node = new ExtAspNet.TreeNode(); //node.NodeID = "0"; //node.Text = "全部"; //node.IconUrl = "~/Icons/package.png"; //node.AutoPostBack = true; //node.Expanded = true; //node.EnableCheckBox = true; if (dtColumn != null && dtColumn.Rows.Count != 0) { foreach (DataRow dr in dtColumn.Rows) { if (dr["PARENT_ID"].ToString() == string.Empty) { ExtAspNet.TreeNode nodeChild = new ExtAspNet.TreeNode(); nodeChild.NodeID = dr["DEPT_ID"].ToString(); nodeChild.Text = dr["DEPT_NAME"].ToString(); //node.IconUrl = nodeChild.EnableCheckBox = true; nodeChild.Expanded = true; nodeChild.AutoPostBack = true; foreach (DataRow drf in dtFun.Rows) { if (dr["DEPT_ID"].ToString() == drf["DEPT_ID"].ToString()) { nodeChild.Checked = true; nodeChild.Expanded = true; } } CreateColumnTree(dr["DEPT_ID"].ToString(), nodeChild, dtColumn, dtFun); tree.Nodes.Add(nodeChild); } } } }
///// <summary> ///// 绑定行的值 ///// </summary> //public void DataBindRow() //{ // #region old code // //// 如果没有初始化Values,则初始化 // //if (Values == null) // //{ // // GridColumnCollection columns = _grid.Columns; // // // 计算每列的值 // // Values = new object[columns.Count]; // // ExtraValues = new object[columns.Count]; // // for (int i = 0, count = columns.Count; i < count; i++) // // { // // Values[i] = columns[i].GetColumnValue(this); // // } // // // 计算DataKeys的值 // // if (_grid.DataKeyNames != null) // // { // // string[] keyNames = _grid.DataKeyNames; // // DataKeys = new object[keyNames.Length]; // // for (int i = 0, count = keyNames.Length; i < count; i++) // // { // // DataKeys[i] = GetPropertyValue(keyNames[i]); // // } // // } // // //// CheckBoxField需要特殊处理 // // //for (int i = 0, count = columns.Count; i < count; i++) // // //{ // // // CheckBoxField cbField = columns[i] as CheckBoxField; // // // if (cbField != null) // // // { // // // cbField.IniValues(); // // // } // // //} // //} // #endregion //} #endregion #region GetPropertyValue ///// <summary> ///// 取得属性的值 ///// </summary> ///// <param name="rowObj"></param> ///// <param name="propertyName"></param> ///// <returns></returns> //public object GetPropertyValue(string propertyName) //{ // //return ObjectUtil.GetPropertyValue(_dataItem, propertyName); //} #endregion #region old code //internal TreeNode AddNode() //{ // TreeNode node = new TreeNode(); // Nodes.Add(node); // return node; //} #endregion #region ReadXmlAttributes internal void ReadXmlAttributes(XmlAttributeCollection attributes, Tree tree) { foreach (XmlAttribute attribute in attributes) { string name = attribute.Name; if (tree != null && tree.Mappings.Count > 0) { name = tree.GetXmlAttributeMappingTo(name); } SetPropertyValue(name, attribute.Value); } }
private Tree InitTreeMenu() { Tree treeMenu = new Tree(); treeMenu.ID = "treeMenu"; treeMenu.EnableArrows = true; treeMenu.ShowBorder = false; treeMenu.ShowHeader = false; treeMenu.EnableIcons = false; treeMenu.AutoScroll = true; Region2.Items.Add(treeMenu); // 绑定 XML 数据源到树控件 treeMenu.DataSource = XmlDataSource1; treeMenu.DataBind(); // 重新设置每个节点的图标 ResolveTreeNode(treeMenu.Nodes); return treeMenu; }