Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Multiple expands for tree (Read 2999 times)
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Multiple expands for tree
Sep 7th, 2011 at 10:26am
Print Post  
I have a flowchart (tree) where some nodes are expandable. I two problems that are easier to explain using pictures. I have the following diagram:




You can see that I have the nodes 3 and 3.1.1 are expandable. The numbers are nodes that are grouped with their nearest node. When I collaplse 3.1.1, I get the picture below. The issue here is that the number 3.1.1 disappears, even though the node is still visible. I dont understand why the number disappears, but the node is still there, even when I have grouped them together.




The major issue is what happens when I collapse 3, and then expand it again. The picture below represents what happens. You can see that I can't even see 3.1.1, even though it still exists in the diagram.



What am I doing wrong? Here is the code I use to create the green nodes, and create the label for the numbers:

function addPlanToNode(parentNode) {
var node = diagram.getFactory().createShapeNode(50, 50, nodeMinWidth, nodeMinHeight);
node.setTag(planTag);
node.setBrush(script.createSolidBrush(170, 230, 170));
node.setId(diagram.getTag());
node.setExpandable(true);
diagram.getFactory().createDiagramLink(parentNode, node);
return node;
}


       function addBoxNumberLabel(node) {
           var label = diagram.getFactory().createShapeNode(
                       node.getBounds().getX(),
                       node.getBounds().getY() - 4,
                       node.getBounds().getWidth(),
                       4);

           label.setTransparent(true);
           label.setIgnoreLayout(true);
           label.setLocked(true);
           label.setTag('number');

           var format = script.createTextFormat(0,0,false,false);
           label.setTextFormat(format);

           var group = node.getSubordinateGroup();
           if (group == null) {
               group = diagram.getFactory().createGroup(node);
               group.setAutoDeleteItems(true);
               group.setExpandable(true);
           }
           group.attachToCorner(label, 0);
           return label;
       }
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Multiple expands for tree
Reply #1 - Sep 7th, 2011 at 11:29am
Print Post  
The default is to expand only one level below the clicked node. Set Diagram.RecursiveExpand = true to expand the tree fully.

Group.Expandable is used to propagate collapse/expand through groups in the same way as through links. It hides all groups in the collapsed branch, including the one of the root node. I suppose we could add some option to ignore the root's group for the next release. Until then you could handle treeCollapsed and call setVisible(true) on the root's group to show the label again.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Re: Multiple expands for tree
Reply #2 - Sep 8th, 2011 at 9:13am
Print Post  
Thanks Stoyo,

I am trying to get my own expanding/collapsing code to work using the techniques in this thread -
http://mindfusion.eu/Forum/YaBB.pl?board=wpfdg_disc;action=display;num=126769720...

I'm stuck on the first part, where my custom expand/collapse function is not running. Could you have a look. This is the code I am using:

<ndiag:DiagramView
                                   ID="DiagramView1"
                                   runat="server"
                                   ClientSideMode="JavaApplet"
                                   Height="450px"
                                   Width="100%"
                                   JarLocation="JDiagram.jar"
                                   AllowInplaceEdit="true"
                                   Behavior="DoNothing"
                                   AppletStartedScript="onAppletStarted"
                                   NodeClickedScript="onNodeClicked"
                                   NodeCreatedScript="onNodeCreated"
                                   NodeDeletingScript="onNodeDeleting"
                                   LinkDeletingScript="onLinkDeleting"
                                   EnterInplaceEditScript="onEnterInplaceEditScript"
                                   NodeTextEditingScript="onTextEditing"
                                   NodeTextEditedScript="onTextEdited"
                                   InplaceEditCancelOnEsc="false"
                                   ExpandButtonClickedScript="onExpandButtonClickedScript"
                                   DelKeyAction="DeleteSelectedItems">
                                   <Diagram
                                       AlignToGrid="False"
                                       AutoResize="AllDirections"
                                       BackBrush="s:#FFE3E3E3"
                                       ExpandButtonAction="RaiseEvents"
                                       LinkBrush="s:#FFABABAB"
                                       LinkHeadShape="Triangle"
                                       LinkHeadShapeSize="3"
                                       LinkSegments="2"
                                       LinkStyle="Cascading" />
                           </ndiag:DiagramView>

       function onExpandButtonClickedScript(sender, args) {
           alert('here');
       }
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Multiple expands for tree
Reply #3 - Sep 8th, 2011 at 10:23am
Print Post  
It seems that's a bug - the ExpandButtonAction value is not transferred to the applet. Try setting it from the AppletStarted event for the time being.

Stoyan
  
Back to top
 
IP Logged
 
jagdipa
Junior Member
**
Offline


I love YaBB 1G - SP1!

Posts: 52
Joined: Jun 23rd, 2011
Re: Multiple expands for tree
Reply #4 - Sep 8th, 2011 at 1:38pm
Print Post  
Just thought I would share the code that I've created. Hopefully it will help anyone else stuck on this.

The code 'remembers' which nodes have collapsed, and leaves them collapsed, even when the parent is expanded.

       function onExpandButtonClickedScript(sender, args) {
           var node = args.getNode();
           expandCollapseNode(node.getExpanded(), node);
       }

       function expandCollapseNode(expand, parentNode)
       {
           var parentLinkCount = 0;

           while (parentLinkCount < parentNode.getOutgoingLinks().size()) {
               var link = parentNode.getOutgoingLinks().get(parentLinkCount);
               var node = link.getDestination();
               var group = node.getSubordinateGroup();
               group.setVisible(expand);

               var nodeExpandedFlag = node.getExpanded()
               if (expand && nodeExpandedFlag)
               {
                   link.setVisible(true);
                   expandCollapseNode(true,node);
               } else if (expand && !nodeExpandedFlag) {
                   link.setVisible(true);
                   expandCollapseNode(false,node);
               } else {
                   link.setVisible(false);
                   expandCollapseNode(false,node);
               }
               //link.setVisible(expand);
               parentLinkCount += 1;
           }
       }
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint