cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1865
Views
0
Helpful
6
Replies

Adding new NodeSet

viihallja
Level 1
Level 1

Hello,

I am trying to add new NodeSet to topology using the addNodeSet method. However I get "Cannot read property 'parentVertexSetID' of undefined" error. See this fiddle: NeXt nodeset - JSFiddle

What am I missing?

1 Accepted Solution

Accepted Solutions

aaikepae
Cisco Employee
Cisco Employee

addNodeSet is a low level API, you missed second parameter as config, it should look like this:

topo.addNodeSet(topologyData.nodeSet[0],{})

I will update NeXt make the second parameter as optional.

Abu

View solution in original post

6 Replies 6

aaikepae
Cisco Employee
Cisco Employee

addNodeSet is a low level API, you missed second parameter as config, it should look like this:

topo.addNodeSet(topologyData.nodeSet[0],{})

I will update NeXt make the second parameter as optional.

Abu

Thanks, I was able to figure it out by looking at the code.

I have a couple of questions. Is there a method for removing NodeSet from topology? I tried the removeNode method but couldn't make it work. What about adding node to existing NodeSet?

I made a demo, you can refer it. Add node to nodeSet could be a little bit tricky. We don't have that feature before.

http://jsfiddle.net/nextsupport/f2eehbhz/

Abu

Thanks Abu. Any change of implementing the add node to nodeSet method? I would like to be able to add new node to nodeSet without reloading the dataset.

In this demo(removeNode&insertNodetoNodeSet - JSFiddle) I implement a function called 'addNodeToNodeSet', you can use this function. I am not add that to framework yet.

function addNodeToNodeSet(topo, pid, nodeData) {

  if (!topo || !pid || !nodeData) {

    return;

  }

  var graph = topo.graph();

  var nodeSet = topo.getNode(pid);

  if (nodeSet) {

    var vertexSet = nodeSet.model();

    var vertex = graph._addVertex(nodeData);

    vertexSet.addVertex(vertex);

    graph.updateVertexSet(vertex);

    if (!nodeSet.collapsed()) {

      var animation = nodeSet.animation();

      nodeSet.animation(false);

      nodeSet.collapsed(true);

      nodeSet.collapsed(false);

      nodeSet.animation(animation);

    }

  }

}

Abu

viihallja
Level 1
Level 1

Thanks Abu, I got it working.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: