Quantcast
Channel: Northwoods Software - Latest topics
Viewing all articles
Browse latest Browse all 7421

Binding to 'data' (.ofObject())

$
0
0

@Luddy wrote:

I have a node template that looks like this:

   $(go.Node,
        ...,
        $(go.Picture,
            { name : "PIC" },
            new go.Binding("element", "data", data => { return this.createCanvasForData(data); }).ofObject()));

It uses a bit of a kludge to get ahold of the entire node data object for the node under construction: a binding on ‘data’ together w/ ofObject. The createCanvasForData() call needs several properties from data; it’s for this reason that binding to a single property w/in data doesn’t suffice.

So, this works, but it results in createCanvasForData() being called twice for every node that is created using the template, when a model is loaded. It’s not hard to imagine ‘data’ being set at the end of the bottom-up copy / construction of a new node, or something of that kind.

So, a few questions:

Is it possible to refer to ‘data’ during construction of a node via a template, other than through a binding on ‘data’ itself? I don’t really need or want a binding here, in the sense of monitoring changes to ‘data’; this is exclusively for creation of the element in the first place.

Is it possible to get the effect of a binding that refers to several properties in tandem? I’m not at liberty, I think, to aggregate the properties of interest into a single property, because the most important one is the category of the node.

Any other suggestions for how I might get this effect?

Thanks,

-Luddy

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7421

Trending Articles