How to prevent Checked event by confirm box on radtreeview?

3 posts, 1 answers
  1. Dũng
    Dũng avatar
    2 posts
    Member since:
    Jul 2015

    Posted 23 Jul 2015 Link to this post

    I have a radtreeview with checkbox. When I check the checkbox, I want to prevent checked event by clicking 'cancel' on confirm box but it doesnt work. Here is my code:
    <telerik:RadTreeView ID="_tree" runat="server" Skin="Silk" CheckBoxes="true" OnClientNodeChecking='ClientNodeChecking' TriStateCheckBoxes="true" CheckChildNodes="true"></telerik:RadTreeView>


    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;
            }
        }
  2. Dũng
    Dũng avatar
    2 posts
    Member since:
    Jul 2015

    Posted 24 Jul 2015 Link to this post

    I myself find a solution. Using OnClientNodeChecked:

    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();
            }
        }

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Ivan Danchev
    Admin
    Ivan Danchev avatar
    829 posts

    Posted 24 Jul 2015 Link to this post

    Hello,

    Thank you for sharing your solution.

    You can prevent the OnClientNodeClicked event from firing by conditionally canceling the OnClientNodeClicking event depending on the user selection by calling the eventArgs.set_cancel(true); function.

    Regards,
    Ivan Danchev
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top