FineUI 官方论坛
标题:
树控件的问题
[打印本页]
作者:
yan
时间:
2012-4-26 18:26
标题:
树控件的问题
出现了两遍:
[attach]360[/attach]
当我选择某一项时,又出现很多遍:
[attach]361[/attach]
请问这是什么问题?我的前台代码:
<ext
anel ID="
anel6" runat="server" BodyPadding="5px" EnableBackgroundColor="false"
ShowBorder="true" ShowHeader="false" Title="
anel" Width="480px" Height="400px">
<Items>
<ext:Tree ID="TFun" runat="server" Height="400px" ShowBorder="false" ShowHeader="false" AutoScroll="true" EnableArrows="true" Title="Tree">
<Nodes></Nodes>
</ext:Tree>
</Items>
</ext
anel>
后台代码:
/// <summary>
/// 新增框-创建第一层节点
/// </summary>
private void DisplayFunMenu()
{
TFun.Items.Clear();
//获得所有父节点的信息
IList<SysFun> parentSysFun = SysFunManager.GetSysFunByUpFunId();
foreach (SysFun sfParent in parentSysFun)
{
string nodeId = sfParent.FunId.ToString(); //第一层节点Id
string displayName = sfParent.FunName; //第二层节点名称
ExtAspNet.TreeNode fatherNode = this.CreatFunTreeNode(displayName, nodeId); //根据节点信息,创建第一层节点
CreateFunChildTree(nodeId, fatherNode); //创建子节点
TFun.Nodes.Add(fatherNode);//将第一层节点加到tree中
}
}
/// <summary>
/// 新增框--创建第二层节点
/// </summary>
/// <param name="nodeId"></param>
/// <param name="fatherNode"></param>
private void CreateFunChildTree(string nodeId, ExtAspNet.TreeNode fatherNode)
{
//获取当前父节点的所有子节点
IList<SysFun> childSysFun = SysFunManager.GetSysFunListByFunId(int.Parse(nodeId));
foreach (SysFun sfChile in childSysFun)
{
string childNodeId = sfChile.FunId.ToString(); //第二层节点Id
string childDisplayName = sfChile.FunName; //第二层节点名称
ExtAspNet.TreeNode childNode = this.CreatFunTreeNode(childDisplayName, childNodeId); //根据节点信息,创建第二层节点
AddTree(fatherNode, childNode);
}
}
/// <summary>
/// 创建一个树节点,返回一个树节点对象,参数内容是:
/// 节点名称,节点ID,链接地址,正常图标,展开后的图标
/// </summary>
private ExtAspNet.TreeNode CreatFunTreeNode(string strText, string strId)
{
ExtAspNet.TreeNode newNode = new ExtAspNet.TreeNode();
newNode.EnablePostBack = true;
newNode.EnableCheckBox = true;
//newNode.Expanded = true;
newNode.Text = strText;
newNode.NodeID = strId;
return newNode;
}
/// <summary>
/// 树控件复选框事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void TFun_NodeCheck(object sender, ExtAspNet.TreeCheckEventArgs e)
{
if (e.Checked)
{
TFun.CheckAllNodes();
}
else
{
TFun.UncheckAllNodes();
}
}
欢迎光临 FineUI 官方论坛 (https://fineui.com/bbs/)
Powered by Discuz! X3.4