2017-07-30 92 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從您的功能手動訪問模型數據。