Hi again,
first and foremost: we're using the 14.1 components with the latest SR :)
I just found out how to select a WebDataTree node via JavaScript (by setting the currentlySelectNode.set_selected(false) and newNode.set_selected(true), even though I wonder why the 'selected' attribute is missing in the CSOM documentation. It took me a while to find ;)). Unfortunately this doesn't trigger the client-side and server-side SelectionChanging/Changed events that we would really need. Is there another way to select a node on the client-side which DOES trigger these events, or is there maybe another way to trigger these events manually?
Background: A user can select a node (single select) in our WebDataTree, and then there is some validation on the client side on SelectionChanging; afterwards, the SelectionChanged handler in the code-behind does the most important work. Now in one very special case we have to cancel the SelectionChanging event, save the information about what node the user was about to click, do some other stuff (involving a postback) and then we would like to "finish" the selection on the node the user wanted to select.
For that I save the information about the node in a hidden field, and on PageLoad I want to select the node and let the events do the rest. But since the events are not triggered, I am at a loss about what to do. Right now I would just show a message telling the user to click on the node again, but that's not very elegant ;)
Thanks for your help in advance!
Johannes
Hello Johannes,
Please feel free to contact me if you have any additional questions regarding this matter.
After looking further into your requirement what I can suggest is calling the _selectNode with the click browser event, for example.
var tree = $find("WebDataTree1"); var node = tree.getNode(0); tree._selectNode(node, true, "click");
var tree = $find("WebDataTree1");
var node = tree.getNode(0);
tree._selectNode(node, true, "click");
I made a small sample and I am attaching it for your reference. In my application I am handling Initialize client side event of the WebDataTree. In this event I am selecting the first node as suggested above. In this scenario SelectionChanging , SelectionChanged client side events as well as Selection changed server side events are fired.
I hope yuou find this information helpful.
Please let me know if you need any further assistance with this matter.
I am currently looking into this matter for you.
I will keep you poste don my progress and I will get back to you as soon as I have any new information.
Thank you for your patience.
Hello Yana,
okay, so that's the reason why it just selects but doesn't trigger anything. I'd be glad if you could help me out further though, since I don't know what event to pass to that method (I'm not 'fluent' in JavaScript or jQuery, I just have to do it for this workaround to work). Right now I would like to use the _selectNode method in
function pageLoad() {
}
which is the AJAX method triggered on pageLoad, but it doesn't have any events I could pass to _selectNode as event arguments. Can I get a corresponding event another way?
Thanks!
you have to pass a certain event to this method: myTree._selectNode, because it will not work in case of null value.
You can also try to pass the browser event on pageload.
Please let me know if it works now.