Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Get selected node focus (Read 4229 times)
Learner
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Feb 10th, 2021
Get selected node focus
Feb 10th, 2021 at 12:34pm
Print Post  
Hi, we have node double clicked event
Code (Javascript)
Select All
 function onNodeDoubleClicked(sender, args) {
//some code
}
 


In this we have to do 'location.reload();'
This goes to server and reloads the view/diagram, but we lose the selected node focus. We tried using 'session' to pass zoom factor, bounds Width/Height and ScrollLeft/ScrollTop properties but it still does not focus on the selected node area. We would like to know which properties we have to get during double click node and set those in server side when diagram is reloading.
We tried 'Diagram.zoomToRect' just to test in 'onArrange' method but got Uncaught TypeError: rect.center is not a function
    at mdiag.Diagram.zoomToRect (eval at <anonymous> (Home:3), <anonymous>:1:424112)
    at onArrange

Thanks,

« Last Edit: Feb 10th, 2021 at 3:02pm by Learner »  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Get selected node focus
Reply #1 - Feb 10th, 2021 at 2:33pm
Print Post  
Hi,

You could submit diagram.getZoomFactor() and getScrollX/Y() values from client side, and assign them back to DiagramView.ZoomFactor/ScrollLeft/ScrollTop properties on server. Alternatively reassign stored values on client-side, but make sure that happens after the diagram loads from JSON (e.g. when ControlLoadedScript is called).

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
Learner
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Feb 10th, 2021
Re: Get selected node focus
Reply #2 - Feb 10th, 2021 at 3:04pm
Print Post  
Hi Slavcho, I will try and let you know. Thanks
  
Back to top
 
IP Logged
 
Learner
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 3
Joined: Feb 10th, 2021
Re: Get selected node focus
Reply #3 - Feb 10th, 2021 at 3:48pm
Print Post  
Hi Slavcho,
I got selected node ScrollX, ScrollY and ZoomFactor values as
Code (Javascript)
Select All
var diagram = MindFusion.Diagramming.Diagram.find('diagramView1');
            alert(diagram.getScrollX());
            alert(diagram.getScrollY());
            alert(diagram.getZoomFactor());
 



Then reassigned these values after reload as follows:
Code (Javascript)
Select All
location.reload();
var diagram = MindFusion.Diagramming.Diagram.find('diagramView1');
            diagram.setScrollX(457);
            diagram.setScrollY(0);
            diagram.setZoomFactor(100);
            alert("reloaded");
 



But still no luck. It seems, Diagram ScrollX and ScrollY values are going back to 0.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3435
Joined: Oct 19th, 2005
Re: Get selected node focus
Reply #4 - Feb 10th, 2021 at 6:17pm
Print Post  
That code actually changes older diagram instance, while reload does its thing asynchronously (downloading new page, building DOM, etc). You will need to reassign your zoom and scroll values from function whose name you assign to DiagramView.ControlLoadedScript, so it affects new instance. E.g. you can keep the values in browser's local storage, or get them from server.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint