Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic how to redraw Expandbutton on existing nodes (Read 3976 times)
hans
Junior Member
**
Offline


I Love MindFusion!

Posts: 81
Location: Netherlands
Joined: Mar 17th, 2012
how to redraw Expandbutton on existing nodes
Feb 7th, 2013 at 12:02pm
Print Post  
After loading a diagram form string, i use the code below to reposition the expandbutton. (using 1.5 beta)
But the new position of the existing nodes is only visible after moving the node.
How can I update the new position?
i.e. node.invalidate() or diagram1.invalidate() doesn't help.


var ExpandButton = MindFusion.Diagramming.ExpandButton;
var oldGetRect = ExpandButton.prototype.getRect;
ExpandButton.prototype.getRect = function ()
{
     var rect = oldGetRect.apply(this);
     rect.y = this.node.bounds.y;
     return rect;
};
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: how to redraw Expandbutton on existing nodes
Reply #1 - Feb 8th, 2013 at 7:47am
Print Post  
Replace ExpandButton.getRect before loading the diagram and the icons should appear as expected. Or otherwise call node.expandButton.updateContent() before calling invalidate() on the node or diagram.

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


I Love MindFusion!

Posts: 81
Location: Netherlands
Joined: Mar 17th, 2012
Re: how to redraw Expandbutton on existing nodes
Reply #2 - Feb 8th, 2013 at 4:26pm
Print Post  
As I load the diagram from code-behind, i can't find a way to Replace ExpandButton.getRect before loading the diagram.
Then after loading the diagram node.expandButton.updateContent() doesn't seem to have any effect.
This does work: 
node.setExpandable(false); node.setExpandable(true);
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: how to redraw Expandbutton on existing nodes
Reply #3 - Feb 11th, 2013 at 7:31am
Print Post  
You can replace the function from a page load event handler attached before the diagram's own load scripts are attached. That should ensure your handler runs before the diagram's one, which loads data from the server and draw the nodes and their +/- icons:

Code
Select All
<body onload="onLoad()">
...
<ndiag:DiagramView ClientSideMode="Canvas" ... />
...
function onLoad()
{
	var ExpandButton = MindFusion.Diagramming.ExpandButton;
	var oldGetRect = ExpandButton.prototype.getRect;
	ExpandButton.prototype.getRect = function ()
	{
		  var rect = oldGetRect.apply(this);
		  rect.y = this.node.bounds.y;
		  return rect;
	};
} 



Instead of setting <body onload>, you could attach the handlers dynamically (in unobtrusive javascript manner) from a <script> tag appearing before the <DiagramView>.

You can update the location for an individual node using the updateLocation method actually, not updateContent:

Code
Select All
function onNodeClicked(sender, args)
{
	var ExpandButton = MindFusion.Diagramming.ExpandButton;
	var oldGetRect = ExpandButton.prototype.getRect;
	ExpandButton.prototype.getRect = function ()
	{
		var rect = oldGetRect.apply(this);
		rect.y = this.node.bounds.y;
		return rect;
	};

	var node = args.getNode();
	node.expandButton.updateLocation();
	node.invalidate();
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint