This is a migrated thread and some comments may be shown as answers.

How to prevent Checked event by confirm box on radtreeview?

2 Answers 36 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Dũng
Top achievements
Rank 1
Dũng asked on 23 Jul 2015, 10:11 AM
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 Answers, 1 is accepted

Sort by
0
Dũng
Top achievements
Rank 1
answered on 24 Jul 2015, 07:25 AM

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

0
Accepted
Ivan Danchev
Telerik team
answered on 24 Jul 2015, 02:23 PM
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
Tags
TreeView
Asked by
Dũng
Top achievements
Rank 1
Answers by
Dũng
Top achievements
Rank 1
Ivan Danchev
Telerik team
Share this question
or