FineUI 官方论坛
标题:
树控件
[打印本页]
作者:
小锂-东莞
时间:
2012-8-30 03:09
标题:
树控件
官方演示,左边是树,点击节点,右边链接URL,实现类似Iframe的效果,后台代码如下 treeMenu.DataSource = XmlDataSource1;
treeMenu.DataBind();
我的代码:是通过递归一个个节点添加,为何我实现不了官方的演示效果呢?
DataSet dst = DBUtility.DbHelperSQL.Query("select ChsDes,EngDes,Menu_Name,isnull(Url,'')as Url,isnull(Parent_Menu,'')as Parent_Menu from dbo.Training_Menu");
DataRow[] drs = dst.Tables[0].Select("Parent_Menu=''");
foreach (DataRow dr in dst.Tables[0].Rows)
{
if (dr["Parent_Menu"].ToString().Trim() == "")
{
ExtAspNet.TreeNode rootnode = new ExtAspNet.TreeNode();
rootnode.Text = dr["EngDes"].ToString();
if (dr["Url"].ToString() != "")
rootnode.NavigateUrl = dr["Url"].ToString();
DataRow[] drs_Child = dst.Tables[0].Select("Parent_Menu='" + dr["Menu_Name"].ToString() + "'");
if (drs_Child.GetLength(0) != 0)
addnodes(rootnode, drs_Child, dst.Tables[0]);
this.treeMenu.Nodes.Add(rootnode);
}
}
private void addnodes(ExtAspNet.TreeNode rootnode, DataRow[] drs,DataTable tb)
{
foreach (DataRow dr in drs)
{
ExtAspNet.TreeNode tmpnode = new ExtAspNet.TreeNode();
tmpnode.Text = dr["EngDes"].ToString();
if (dr["Url"].ToString() != "")
tmpnode.NavigateUrl = dr["Url"].ToString();
DataRow[] drs_Child = tb.Select("Parent_Menu='" + dr["Menu_Name"].ToString() + "'");
if (drs_Child.GetLength(0) != 0)
addnodes(tmpnode, drs_Child, tb);
rootnode.Nodes.Add(tmpnode);
}
}
欢迎光临 FineUI 官方论坛 (https://fineui.com/BBS/)
Powered by Discuz! X3.4