Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

Require multiple components of the same type with Unique names

$
0
0

@samhita wrote:

I have similar drag and drop palette and diagram as shown in this sample: https://gojs.net/latest/extensions/Robot.html

But here if we drag and drop multiple Alpha nodes. The count increment is happening as the text Binding is with the Key. Which is why we get Alpha, Alpha1, Alpha2 etc.

I want this same increment to happen with a custom node property called ‘componentName’.

my palette structure for a node will be something like this:
{
name: ‘Trigger’,
componentName: ‘Sensor’,
}

Now when i drag multiple components from this palette, i want the names to be Sensor, Sensor1, Sensor2 etc.

How can i achieve this?

This is what I have tried:

$(go.TextBlock, ‘’,
{
row: 0, column: 1,
margin: 10,
textAlign: ‘left’,
verticalAlignment: go.Spot.TopRight,
background: ‘white’,
width: 70,
height: 30,
maxLines: 1,
overflow: go.TextBlock.OverflowEllipsis,
},
new go.Binding(‘text’, ‘’, function(data) {
console.log('data in concat function: ', data);
return data.componentName + Math.abs(data.key);
}).makeTwoWay())

But this only reflects on the View, But my model data is not updated.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles