Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
340
Raise a node click from client?
posted

HI there,

 

We have a webdatatree which we populate on the server and all is well. What I am having problems with though is actually forcing a nodeclick event (which will then raise a postback) from the client-side.

 

I've got the following code (after I find the node) which I know is being executed (i.e the node is highlighted in the tree once called). But no matter which events I try, the postback is just not happening. Ive tried calling toggle, update, and various combo's (as you can see below) but nothing happens.

 

 

 var node = tree.resolveItem(nodeAddress);


            if (node != null) {

                tree.set_activeNode(node, true);

                node.toggle(true);

                node.set_expanded(true, true);

                node._toggleClicked();

                tree.updated();

tree._nodeClick(node, true);

 

 

Is there a simple method i've missed somewhere, all I want to do is call the click event.

 

Many thanks

  • 19693
    posted

    Hello bartond31 ,

    Can you please share your scenario regarding this?

    As Lubomir has suggested the best choice is calling __doPostBack

    The options regarding firing the event do the trick but it is not a standard thing using them.

  • 3726
    Suggested Answer
    posted

    If your purpose is just to raise a postback, why do you just call __doPostBack(treeId, some arguments)?

    To fire just the event you can do:

     

    1) tree

     

     

    ._raiseClientEvent('NodeClick','DataTreeNode',browserEvent,null

    ,node,node._get_address(),browserEvent.button);

    You can pass null for browserEvent and 0 for browserEvent.button.

    2) Another thing you can do is tree._onMouseupHandler(elem, adr, browserEvent)

    elem is reference to node.get_element(), adr is reference to node._get_address(), browserEvent can be passed as null.

    So 1) or 2) should do the trick.

    Hope this helps.

    Thanks,

    Lubomir