如何通过radtreeview上的确认框阻止Checked事件?

时间:2015-07-23 09:52:42

标签: javascript c# asp.net checkbox radtreeview

我有一个带有复选框的radtreeview。当我勾选复选框时,我想通过点击“取消”来阻止检查事件。在确认框但它不起作用。这是我的代码:

<telerik:RadTreeView ID="_tree" runat="server" Skin="Silk" CheckBoxes="true" OnClientNodeChecking='ClientNodeChecking' TriStateCheckBoxes="true" CheckChildNodes="true"></telerik:RadTreeView>

&#13;
&#13;
function ClientNodeChecking(sender, eventArgs) {
        var node = eventArgs.get_node();
        if (node.get_checked()) {
            var agree = confirm('Do you want to check?');
            if (agree) {
                node.check();
            }
            else
                return false;
        }
    }
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

我找到了解决方案。使用OnClientNodeChecked:

&#13;
&#13;
function ClientNodeChecked(sender, eventArgs) {
        var node = eventArgs.get_node();
        if (!node.get_checked()) {
            var agree = confirm('Do you want to check?');
            if (!agree) node.check();
        }
    }
&#13;
&#13;
&#13;