The MindFusion Forums
Flow Diagramming Components >> ASP.NET >> Collapse and keep nodes with multi incoming links
https://mindfusion.eu/Forum/YaBB.pl?num=1495566918

Message started by Ghaith on May 23rd, 2017 at 7:15pm

Title: Collapse and keep nodes with multi incoming links
Post by Ghaith on May 23rd, 2017 at 7:15pm
Hello,

I have a diagram with custom Nodes, and there might be more than one parent to some nodes,
in the collapse of parent, then then child node is hidden even if there is other link,

I want to validate if there is more than one visible IncommingLinks to the child, then keep the child visible.

I tried to set the visible = true to the child node  in TreeCollapsed handler, but it didn't work.

Tried to implement a custom ExpandButtonClicked, but didn't success.

any help

Title: Re: Collapse and keep nodes with multi incoming links
Post by Slavcho on May 23rd, 2017 at 8:35pm
Hi,

Try handling treeCollapsed event like this -

[code]
function onTreeCollapsed(sender, args)
{
     var node = args.node;
     if (node.collapsedSet)
     {
           node.collapsedSet.forEach(function (item)
           {
                 if (item == node)
                       return;
                 if (DiagramNode.isInstanceOfType(item))
                 {
                       var links = item.incomingLinks;
                       var expandBack = false;
                       links.forEach(function (link)
                       {
                             if (link.getVisible())
                                   expandBack = true;
                       });
                       if (expandBack)
                       {
                             item.setVisible(true);
                             item.expand();
                       }
                 }
           });
     }
}[/code]

Regards,
Slavcho

Title: Re: Collapse and keep nodes with multi incoming links
Post by Ghaith on May 24th, 2017 at 5:46pm
Thanks dear it worked.

Title: Re: Collapse and keep nodes with multi incoming links
Post by Ghaith on Jun 2nd, 2017 at 2:22pm
Dear,

I had the same issue when exporting the diagram using PdfExporter, since I had to recreate the diagram in server side, I write a code to re-collapse  collapsed nodes, but I couldn't keep the nodes with multi incoming links

here is my code, where I passed the diagram json value to server

            
Code (]
//Draw diagram
            FillSelectedEntity();

            var json_value = Request.Form["diagram_json"):

;

            if (!string.IsNullOrWhiteSpace(json_value))
            {
                var j_diagram = Json_Diagram.Deserialize(json_value);
                for (int i = 0; i < this.diagramView.Diagram.Items.Count; i++)
                {
                    var t = j_diagram.items.SingleOrDefault(x => x.instanceId == i);
                    if (t == null)
                        continue;

                    var item = this.diagramView.Diagram.Items[i];
                    //Node
                    if (item.Id != null)
                    {
                        var n = item as CustomNode;
                        n.Move(t.bounds.x, t.bounds.y);
                        if (!t.expanded)
                            n.Collapse();
                    }
                }
                this.diagramView.Diagram.RouteAllLinks();
                ResizeDiagramView();
            }

any idea

Title: Re: Collapse and keep nodes with multi incoming links
Post by Slavcho on Jun 5th, 2017 at 7:57am
Instead of rebuilding the diagram, you should be able to send serialized full diagram from client to server. Try calling Diagram.toJson() in JavaScript and DiagramView.LoadFromJson on .NET side, then the visibility of items should be as set in the client-side handler.

Title: Re: Collapse and keep nodes with multi incoming links
Post by Ghaith on Jun 5th, 2017 at 11:42am
Dear,

Thanks for you reply,  but I don't have LoadFromJson function.
I have the following
LoadFromFile
LoadFromStream
LoadFromString
LoadFromXml

Title: Re: Collapse and keep nodes with multi incoming links
Post by Slavcho on Jun 5th, 2017 at 1:06pm
It's in DiagramView class, since version 5.7.

Title: Re: Collapse and keep nodes with multi incoming links
Post by Ghaith on Jun 5th, 2017 at 3:45pm
Dear,

how to check the current version? and how to upgrade to V 5.7?
I have a licensed version.

Title: Re: Collapse and keep nodes with multi incoming links
Post by Slavcho on Jun 5th, 2017 at 5:06pm
Check the readme.txt or properties of diagramming.webforms.dll. If your license was purchased within a year before the v5.7 release, the license key will work for 5.7 too.

Title: Re: Collapse and keep nodes with multi incoming links
Post by Ghaith on Jun 7th, 2017 at 2:50pm
after updating, everything worked perfectly.

thanks for your support

The MindFusion Forums » Powered by YaBB 2.6.11!
YaBB Forum Software © 2000-2024. All Rights Reserved.