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

Revert selection on form cancel

1 Answer 32 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Samuel
Top achievements
Rank 1
Samuel asked on 26 Mar 2009, 03:22 PM
Scenario: I have a tree view on my page, and the code-behind is handling the Node Click event. Thus the tree posts to the form when the user clicks a node. However, I have custom javascript to do form checking and cancel the form under certain conditions. I want the tree view to revert its selection if the form is canceled.

The problem is that the tree view is in a separate web part from the web part that emits the form validation script, so the form validation script doesn't know the ID of the tree view, and can't even necessarily assume that the part with the tree is on the page. What would you suggest I do to solve my problem?

1 Answer, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 30 Mar 2009, 09:00 AM
Hello Samuel,

You can try the following:
1. define a global variable, e.g.

    var treeViewID;

2. Subscribe to OnClientLoad event of the treeview and set the global variable to the ID of the treeview:
function onClientLoadHandler(sender, e) 
   treeViewID = sender.get_id(); 

Now, you can use the treeViewID global variable to find the treeview in your validation code:

var tree = $find(treeViewID);

I hope this will get you started.

All the best,
Veselin Vasilev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
TreeView
Asked by
Samuel
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Share this question
or