Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Get Value Node Javascript (Read 4019 times)
Eli1983
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 12th, 2008
Get Value Node Javascript
Aug 12th, 2008 at 11:48am
Print Post  
Hi!!

Sorry about my english, not native speaker ^^U

I need to get the node identifier wich is automatically generetad when the node is added, with javascript.

I've tried using getNode(), but I can only access to the text value, not the ID.
Any help?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3347
Joined: Oct 19th, 2005
Re: Get Value Node Javascript
Reply #1 - Aug 12th, 2008 at 12:29pm
Print Post  
Hi,

There aren't any automatically generated identifiers. You can assign your own id-s to the Tag property of nodes.

HTH
  
Back to top
 
IP Logged
 
Eli1983
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 12th, 2008
Re: Get Value Node Javascript
Reply #2 - Aug 12th, 2008 at 12:45pm
Print Post  
Hi,

How can I assign my own id-s to the Tag property of nodes when I add a node in mode design to diagram?

Thanks in advance.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3347
Joined: Oct 19th, 2005
Re: Get Value Node Javascript
Reply #3 - Aug 12th, 2008 at 1:34pm
Print Post  
Handle the NodeCreated event, and set the e.Node.Tag to the id value you want to use, for example

e.Node.Tag = (new Guid()).ToString();

HTH
  
Back to top
 
IP Logged
 
Eli1983
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 12th, 2008
Re: Get Value Node Javascript
Reply #4 - Aug 13th, 2008 at 8:04am
Print Post  
Hi,

I defined the event this:

diagramView.Diagram.NodeCreated += new NodeEventHandler(Diagram_NodeCreated);

  protected void Diagram_NodeCreated(object sender, NodeEventArgs e)
    {
       throw new Exception("The method or operation is not implemented.");
    }

But the exception doesn´t throw.

I tried the same whith NodeDeleted event and not ocurred nothing

What am I doing wrong?

Thanks for all!

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3347
Joined: Oct 19th, 2005
Re: Get Value Node Javascript
Reply #5 - Aug 13th, 2008 at 8:15am
Print Post  
Hi, are you using the Windows Forms Flowchart.NET control?
  
Back to top
 
IP Logged
 
Eli1983
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 12th, 2008
Re: Get Value Node Javascript
Reply #6 - Aug 13th, 2008 at 8:45am
Print Post  
Sorry, I´m using the NetDiagram :$

But these events not working same?

  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3347
Joined: Oct 19th, 2005
Re: Get Value Node Javascript
Reply #7 - Aug 13th, 2008 at 9:02am
Print Post  
Nope. You must set DiagramView.NodeCreatedScript to the name of a JS function that will handle the event, e.g.

function onNodeCreated(sender, e)
{
e.getNode().setTag(...);
}

I don't know if there is a method to generate GUID in JS, but you can use another kind of ID, for example the current time + the number of items in the diagram at this time.

HTH
  
Back to top
 
IP Logged
 
Eli1983
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 12th, 2008
Re: Get Value Node Javascript
Reply #8 - Aug 13th, 2008 at 9:11am
Print Post  
First sorry about the mess

In server side I get the IndexOf of nodes of my diagram this way:

  foreach (DiagramNode di in diagramView.Diagram.Nodes)
               nodosiniciales.Add(diagramView.Diagram.Nodes.IndexOf(((ShapeNode)di)));

Now I want to get this value from javascript

Is there any way to do it?

Thanks for advance!!
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3347
Joined: Oct 19th, 2005
Re: Get Value Node Javascript
Reply #9 - Aug 13th, 2008 at 1:27pm
Print Post  
Hi,

You can do it as below with the Java API -
diagramView.getDiagram().getNodes().indexOf(di)

however indexOf does a linear search, and you'd better do that using an integer counter

for (i = 0; i < ...getNodes().size(); ++i)
nodosiniciales.add(i);

To me that looks the same as your foreach ... indexof ... loop.

HTH
  
Back to top
 
IP Logged
 
Eli1983
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 6
Joined: Aug 12th, 2008
Re: Get Value Node Javascript
Reply #10 - Aug 14th, 2008 at 9:19am
Print Post  
it works fine!
Thanks for the help!!

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint