【问题标题】:how to get the updated model after the diagram change?图表更改后如何获取更新的模型?
【发布时间】:2017-07-30 00:03:35
【问题描述】:
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;
};

我想知道如何在 OkName 函数之外获取 newstr?我想收集所有的 newstr。

谢谢!

【问题讨论】:

  • 改进格式

标签: gojs


【解决方案1】:

您的go.TextBlock 应该具有双向绑定,因此当文本被接受(验证成功)时,您的文本将保存到模型中。

例如

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-23
    相关资源
    最近更新 更多