RadTreeView 控件中的复选框行为
我正在使用 Telerik RadTreeView 控件构建一棵树,其 包含复选框的节点。
此控件的默认行为是,如果检查父节点,则其内的所有子节点也将被检查。有什么办法可以改变这种行为吗?我希望能够检查父节点的打开或关闭,并且不让它影响子节点。
谢谢
I am using a Telerik RadTreeView control to build a tree with nodes containing checkboxes.
The default behavior for this control is that if you check a parent node, all of the child nodes within it will also become checked. Is there any way to change this behavior? I want to be able to check a parent node on or off and not have it affect the children.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当 PreviewChecked 事件发生时,我会尝试做一些魔法。我不确定,但也许您可以使用它来检测即将选中的复选框,并在不是用户实际单击的复选框时防止这种情况发生。
I would try doing some magic when the PreviewChecked event happens. I'm not sure, but maybe you can use it to detect a checkbox is about to become checked, and prevent this from happening if it is not the checkbox the user actually clicked in.
您还可以在 javascript 中执行一些操作,如下所示。
这直接来自 telerik,但只需循环遍历所有子节点并将它们关闭(或在单击关闭时重新打开)。问题是如果您想维护子节点的状态而不管父节点如何。然后你需要将该信息保存在某个变量中。
另一种选择是,如果您不希望子级有复选框,则只需不要在服务器端代码中使这些节点“可检查”。 (我确信客户端也有办法)
You could also do some stuff in javascript like this
This is straight from telerik but simply loop through all the children nodes and turn them back off (or back on when you click it off). The problem is if you want to maintain the state of the children nodes regardless of the parent. Then you need to hold that info in some variable.
The other option is if you don;t want the children to even have checkboxes, then simply don;t make those nodes "Checkable" in the server side code. (I'm sure there is a way in the client side too)