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
395
Using ClientEvents to show different icon when node expanded/collapsed
posted

Hello,

i want to change the imageurl on client, if a node is expanded or collapsed. In my case i want to show a FolderClose-icon if node collapsed and a FolderOpen-icon if it is expanded. I can do that in server-side code but this causes a roundtrip to the server.

Is there a possibility to do that on client? I saw the ClientEvents NodeExpanded and NodeCollapsed but no methods to change the imageurl. Or is it possible to do that via CSS?

Thanks

Martin

Parents
No Data
Reply
  • 49378
    posted

    Hi Martin,

    Thank you for posting in the community.

    It is possible to change the image source of a node by accessing the respective html element. Below is some sample code illustrating how this can be achieved for node expansion using jQuery:

    function WebDataTree1_NodeExpanded(sender, eventArgs) {

        //get the node element and subsequently change the node image's src

        var nodeElement = eventArgs.getNode().get_element();
        $(nodeElement).children(".igdt_NodeImage").first().attr("src", "ig_res/Default/images/add_down.gif");
    }

    Please let me know if this helps.

Children