2017-07-30 49 views
0
myDiagram.nodeTemplateMap.add("decision", 
     $(go.Node, "Auto", 
     new go.Binding("text", "text"), 
     // define the node's outer shape, which will surround the Horizontal Panel 
     $(go.Shape, "Rectangle", 
      { fill: "yellow", stroke: "lightgray" }), 
     // define a horizontal Panel to place the node's text alongside the buttons 
     $(go.Panel, "Horizontal", 
      $(go.TextBlock, 
      { editable: true, font: "15px Roboto, sans-serif", margin: 5, textValidation: okName}, 
      //textValidation: okAnswer}, 

function okName(textblock, oldstr, newstr) { 
    return true; 
}; 

我想知道如何获得OkQuery函数以外的newstr?我想收集所有的newstr。图表更改后如何获取更新后的模型?

谢谢!

+0

改进格式 –

回答

1

您的go.TextBlock应该有一个双向绑定,所以当文本被接受(验证成功),您的文本被保存到模型。

例如

new go.Binding("text", "text").makeTwoWay() 

如果不希望文本保存到模型中,您可以在验证函数内保存newstr到一个自定义的数组或任何你喜欢的。 您还可以使用textblock.part.data从您的功能手动访问模型数据。