Reputation: 537
I'm having two panels GoJs Diagram similar to http://gojs.net/latest/samples/flowchart.html. I drop objects from left panel to main diagram. How do I get/set values of attributes ob dropped object like text etc.? I'm stuck with
myDiagram.addDiagramListener("ExternalObjectsDropped",
function (e) {
var part = e.subject;
console.log(e.subject);
});
Console only shows very complicated object structure, but I don't know where to find values I'm searching for. My main goal is to resize some TextBlocks of dropped object.
Upvotes: 2
Views: 1784
Reputation: 4146
First, understand that the model data in the source Diagram will be copied to the model of the destination Diagram. So whatever enumerable properties you have on the node data objects in the source should appear on the node data objects of the Nodes created in the destination.
Second, why do you want to "resize some TextBlocks" in the copied Node(s)? If their TextBlock.text properties are data bound to properties in the copy node data object, then what you really want to do is modify those properties on the model data. So your "ExternalObjectsDropped" listener could do:
function(e) {
// according to the documentation e.subject in this case is
// the Diagram.selection, a Set of the copied Parts
e.subject.each(function(node) {
var model = e.diagram.model;
model.setDataProperty(node.data, "myProp1", ...);
model.setDataProperty(node.data, "myProp2", ...);
});
}
Alternatively, if you really want to change the GraphObject.desiredSize or any other property of the TextBlocks, you can do that explicitly by giving each TextBlock a GraphObject.name and calling Panel.findObject to find that particular TextBlock in a particular Node.
The page http://gojs.net/latest/learn/graphObject.html provides more discussion.
Upvotes: 3