The correct way of adding groups from a Pallete

Hi,

I created a button to add new Swimlanes to my diagram like that:

myDiagram.nodeTemplateMap.add(“NewLane”,
$(go.Node, “Auto”,
{locationSpot: go.Spot.Center},
$(“Button”, {
text: “New Swimlane”,
click: newLane
}
)
));

myPalette = $(go.Palette, "myPalette", {
    nodeTemplateMap: myDiagram.nodeTemplateMap,
    model: new go.GraphLinksModel([
        { category: "NewLane" },
    ])
});

<font color="#0000CC">function newLane() {
    myDiagram.startTransaction("newLane");

    myDiagram.model.addNodeData({
            key: 'myKey',
            text: 'myText',
            isGroup: true,
            height: 100
    });
        
    myDiagram.commitTransaction("newLane");
}</font></font>

Doing like this it doesn’t save the parameters (like height) when the diagram is saved.

I have the deep feeling that this is not the right way to do.

Can you enlighten?

Thank you

Some inconsistencies: the node data in the Palette has a category but does not state that is a group; the node data that you add in the newLane function is a group but does not specify a category; you added the “NewLane” template to the collection of node templates, not the group templates.

[QUOTE=walter]Some inconsistencies: the node data in the Palette has a category but does not state that is a group; the node data that you add in the newLane function is a group but does not specify a category; you added the “NewLane” template to the collection of node templates, not the group templates.

[/quote]

Can you tell me how to add it to the group templates instead of the node templates? Couldn’t find it.

Thanks

Either set Diagram.groupTemplate or add to Diagram.groupTemplateMap.

Just as with node templates, if you only have one template, you can set Diagram.groupTemplate and not bother at all to set the category on the data.

But if you want multiple group templates, you can either require category to be set on all of the data, or you can assign the default group template, whose name is the empty string. Then you would only need to set the category when you wanted to use a template other than the default one.

Hi again,

Sorry, but I am struggling for too long with this issue. Tried pretty much every thing I could find.

Is there an example where you resize a Node and generate the JSON with the resized WIDTH and HEIGHT?

Thank you again

sorry man.

was just missing the .makeTwoWay()

thanks