Hi there, i was wondering if you can make that the nodetemplate can vary depending of what it receives for example i can show a shape by default but if the palette node have a source of an image just show that instead of the shape.
Sure, there are several ways to accomplish that, depending on how you want to organize your data.
You could use different templates, as described at GoJS Template Maps -- Northwoods Software and demonstrated in many samples. Usually the templates are significantly different from each other structurally, and I don’t think that makes the most sense in your situation.
Or, you could have both a Shape and a Picture occupying the same area in your node, with the Picture in front. If the binding for the Picture.source successfully assigns the source URL and if the image loads successfully, then it will be seen in front of the Shape, blocking it. (Assuming the image is opaque, but you can data bind the Picture.background to make sure it is opaque if there is an image.)
Or, you could have a default image that is the default setting for Picture.source. The binding of Picture.source to your data, if present and if loaded successfully, would replace that default image file. This way you don’t need different templates or even an extra Shape that would be useless when there is an image. The downside is that if the image is specified but it does not load successfully, you’ll see nothing there.