如何在分隔输入中手动设置节点和 link 文本?
How can I set node and link text manually in separated input?
我有一个简单的 python flask 应用程序,我将 JSON
数据发送到我的 HTML
并使用 goJS
我显示我的图表,如下所示:
我想在输入中更改我选择的节点文本,当我单击 "update node text"
按钮时,我想用我的 input
中的文本更新节点文本。在这个图表监听器的帮助下,我设法获得了节点文本:
myDiagram.addDiagramListener("ObjectSingleClicked", function(e) {
console.log("clicked!");
var part = e.subject.part;
//part.data is the node object
if (!(part instanceof go.Link)) {
console.log("its not link!");
console.log(part.data);
document.getElementById("nodeText").value = part.data.text;
} else {
console.log("its link!");
}
});
我被更新节点文本困住了,不知道该怎么做。我也想用 link 文本做同样的事情。我进行了搜索和谷歌搜索,但没有针对此案例的解决方案或示例。任何帮助将不胜感激。
首先我要说的是,允许用户在图表中编辑文本的最常见方法是将 TextBlock.editable to true and to add a TwoWay Binding of TextBlock.text 设置为一些数据 属性。这允许用户就地编辑文本,而不是在单独的 HTML 字段中。
但在 HTML 字段中编辑属性是很常见的。假设至少有一种方法从某些数据 属性 绑定到节点中的 TextBlock.text 属性,则文本区域的模糊(或更改? ) 事件处理程序只需要调用 Model.setDataProperty within a transaction. Read more about modifying models and transactions.
最后,如果您有一堆属性要允许用户编辑,尤其是属性的数量可能会有所不同,您可能需要使用 GoJS DataInspector. It is demonstrated by the Org Chart Editor sample and the Data Inspector sample。
我有一个简单的 python flask 应用程序,我将 JSON
数据发送到我的 HTML
并使用 goJS
我显示我的图表,如下所示:
我想在输入中更改我选择的节点文本,当我单击 "update node text"
按钮时,我想用我的 input
中的文本更新节点文本。在这个图表监听器的帮助下,我设法获得了节点文本:
myDiagram.addDiagramListener("ObjectSingleClicked", function(e) {
console.log("clicked!");
var part = e.subject.part;
//part.data is the node object
if (!(part instanceof go.Link)) {
console.log("its not link!");
console.log(part.data);
document.getElementById("nodeText").value = part.data.text;
} else {
console.log("its link!");
}
});
我被更新节点文本困住了,不知道该怎么做。我也想用 link 文本做同样的事情。我进行了搜索和谷歌搜索,但没有针对此案例的解决方案或示例。任何帮助将不胜感激。
首先我要说的是,允许用户在图表中编辑文本的最常见方法是将 TextBlock.editable to true and to add a TwoWay Binding of TextBlock.text 设置为一些数据 属性。这允许用户就地编辑文本,而不是在单独的 HTML 字段中。
但在 HTML 字段中编辑属性是很常见的。假设至少有一种方法从某些数据 属性 绑定到节点中的 TextBlock.text 属性,则文本区域的模糊(或更改? ) 事件处理程序只需要调用 Model.setDataProperty within a transaction. Read more about modifying models and transactions.
最后,如果您有一堆属性要允许用户编辑,尤其是属性的数量可能会有所不同,您可能需要使用 GoJS DataInspector. It is demonstrated by the Org Chart Editor sample and the Data Inspector sample。