2 Replies Latest reply on Sep 24, 2012 12:30 PM by just-greg

    RF 4.2 expand tree node on click

    true_mykola

      Hi, i made my tree to expand/collapse on node clicking (without +/- icons) by calling toggle() method from tree.js but i have one little problem: everytime i click on a "folder" node treeSelectionChangeListener is called. Is it possible to call it only when i click on leaf nodes? I've added toggleType="client" but it seems like it only preloads nodes and it doesn't prevent listener to be called

        • 1. Re: RF 4.2 expand tree node on click
          true_mykola

          I made it! I used some internal javascript in onbeforeselectionchange event of tree:

          onbeforeselectionchange="if (arguments[2].newSelection[0].__canBeToggled()) { arguments[2].newSelection[0].toggle();return false;}"
          

          Maybe it's a little bit dirty but it works

          • 2. Re: RF 4.2 expand tree node on click
            just-greg

            I realize this post is a few months old, but it's also the only one out there recently....and it's very dirty as he said...

            So I thought I would post a cleaner approach to this.

             

            Which would be this:

            {code}onclick="#{rich:component('treeNodeId')}.expand();"{code}

             

            {code}onclick="#{rich:component('treeNodeId')}.collapse();"{code}

             

             

            I believe toggle would also be valid although I've never used it personally.