• epoint:TreeView


    Epoint.Web.UI.WebControls2X.EpointTreeNode 

    思路:就是使用递归


    RootNodeText 根节点名称
    RootNodeUrl 根节点路径
    ShowRootNode 是否显示根节点

    OnTreeNodePopulate 动态添加子节点事件 如果节点的表明node.PopulateOnDemand = 

    true;那么这是一个动态添加的节点

    一层节点

    <epoint:TreeView ID="TreeView1" Target="main1" SearchAtClient="false" runat="server" ShowRootNode="true" RootNodeText="所有商品" RootNodeUrl="Record_List.aspx">
        </epoint:TreeView>
    
    
          protected void Page_Load(object sender, EventArgs e)
            {
    
                this.CurrentLeftPosition = "选择商品";
                this.CurrentRightPosition = "商品列表";
                this.CurrentPosition = "商品管理";
                if (!Page.IsPostBack)
                    BindTree();
            }
            protected void BindTree()
            {
               
                DataView dvCommunityInfo = new DB_Commodity().Select();
                Epoint.Web.UI.WebControls2X.EpointTreeNode node;
                for (int i = 0; i < dvCommunityInfo.Count; i++)
                {
                    node = new EpointTreeNode();
                    node.Text = dvCommunityInfo[i]["Name"].ToString();
                    node.Value = dvCommunityInfo[i]["RowGuid"].ToString(); 
                    node.NavigateUrl = "Record_List.aspx?CommidityGuid=" + node.Value;
                    TreeView1.Nodes.Add(node);
                }
            }    

    两层节点

    public partial class XMTree : BaseContentPage_UsingMasterWithTree
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!Page.IsPostBack)
                {
                    this.CurrentLeftPosition = "项目信息";
                    this.CurrentRightPosition = "项目信息";
                    this.CurrentPosition = "项目信息";
                    BindXMTreeData();
                }
            }
            public void BindXMTreeData()
            {
                TreeView1.RootNodeText = "各类型项目";  //获取根节点文本 
                AddTopNodes();
            }
    
            private void AddTopNodes()
            {
                EpointTreeNode node;
                string sqlGCValue = string.Format(@"select ItemValue,ItemText from VIEW_CodeMain_CodeItems where CodeName='{0}'", "项目库工程类型");
                DataView dv = Epoint.MisBizLogic2.DB.ExecuteDataView(sqlGCValue);
                DataView dvTemp;
                for (int i = 0; i < dv.Count; i++)
                {
                    node = new EpointTreeNode();
                    node.Text = Convert.ToString(dv[i]["ItemText"]);
                    node.Value = Convert.ToString(dv[i]["ItemValue"]);
                    string sqlXMtype = string.Format(@"select ItemValue,ItemText from VIEW_CodeMain_CodeItems where CodeName='{0}' and ItemValue like '" + Convert.ToString(dv[i]["ItemValue"]) + "%'", "项目库项目类型");
                    dvTemp = Epoint.MisBizLogic2.DB.ExecuteDataView(sqlXMtype);
                    TreeView1.Nodes.Add(node);
                    if (dvTemp.Count > 0)
                        expandChildNodes(node, dvTemp);     //实时加载子节点
                }
    
            }
    
            /// <summary>
            /// 递归绑定子节点
            /// </summary>
            /// <param name="parentNode"></param>
            /// <param name="dv"></param>
            private void expandChildNodes(EpointTreeNode parentNode, DataView dv)
            {
                EpointTreeNode node; 
                string fullItemText = "";
                string[] TextArr;
                for (int i = 0; i < dv.Count; i++)
                {
                    node = new EpointTreeNode();
                    fullItemText = Convert.ToString(dv[i]["ItemText"]);
                    if (fullItemText.Contains(""))
                    {
                        TextArr = fullItemText.Split('');
                        node.Text = TextArr[1];
                    }
                    else
                    {
                        node.Text = Convert.ToString(dv[i]["ItemText"]);
                    }
                    node.Value = Convert.ToString(dv[i]["ItemValue"]);
                    node.NavigateUrl = "NodeWeightConfigTree.aspx?projecttype=" + node.Value + "&firstnodename=" + node.Text;
                    parentNode.ChildNodes.Add(node); //添加子节点
                }
            } 
        }

     

  • 相关阅读:
    获得spring代理对象的原对象
    自动注入bean,简化持久化
    java Instrument修改字节码实现aop功能
    c# 笔记
    js 字符串与json互转
    js Deferred的使用
    chrome 插件开发 通讯机制
    ajax 采用XMLHttpRequest post、get 发送数据
    [转]c fscanf 按行读取文件_(Testbench用法总结)1. Testbench中文本数据的存储读取操作对比...
    转:VIVADO使用技巧:设置DCI与内部参考电压
  • 原文地址:https://www.cnblogs.com/panmy/p/5876716.html
Copyright © 2020-2023  润新知