Dynamically adding node data array

Hi there,

I need help on how to add node data array from json string when trying with the code below i get: this[(palettes[i].PaletteName + palettes[i].Id.toString(…))].addNodeData is not a function

var savedFile = palettes[i].Layout;
var obj = JSON.parse(savedFile);
this[palettes[i].PaletteName + palettes[i].Id.toString()].model = $(go.GraphLinksModel,
copiesArrays: true,
copiesArrayObjects: true,

                    });  // end model
                for (var i = 0; i < obj.length; i++) {
                    this[palettes[i].PaletteName + palettes[i].Id.toString()].addNodeData(obj[i]);

addNodeData (or addNodeDataCollection) are methods on Model, not on Diagram (or Palette).

So if palettes is an Array of Palettes, you need to get each Diagram.model before you can call its method.

Thanks Walter,

That worked awesome.