树的初始状态
<ext:Tree ID="tvGW_QX_MK" runat="server" ShowBorder="false" ShowHeader="false"
>
</ext:Tree>
创建树节点:
fillQX_GW_GNMKTREE("142900400000001");
private void getGNMKNode(string JD_DM, List<V_QX_GW_GNMK> GLMKS, TreeNode Root)
{
//TreeNode tt = new TreeNode();
var subNodes = GLMKS.Where(p => p.FJD_DM == JD_DM).ToList();
if (subNodes.Count > 0)
{
Root.Leaf = false;
foreach (var sn in subNodes)
{
TreeNode t = new TreeNode();
t.Text = sn.JD_MC;
t.NodeID = "t" + sn.JD_DM;
t.EnableCheckBox = true;
t.EnablePostBack = true;
//如果授权标志不为空,则将CHK选中
if (!string.IsNullOrEmpty(sn.SQBZ))
{
t.Checked = true;
t.Expanded = true;
}
getGNMKNode(sn.JD_DM, GLMKS, t);
Root.Nodes.Add(t);
}
Root.Expanded = true;
}
else
{
Root.Leaf = true;
}
NodeCheck事件:
protected void tvGW_QX_MK_NodeCheck(object sender, ExtAspNet.TreeCheckEventArgs e)
{
if (!e.Node.Leaf)
{
CheckTreeNode(e.Node.Nodes, e.Checked);
}
}
调试时发现,事件根本不回发!
和示例比较时发现可能的原因是节点是动态创建,是否动态创建的节点的NodeCheck事件没有注册?
|