私は私が送るシンプルなPythonのフラスコアプリ持つ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!");
}
});
ノードテキストの更新に行き詰まっていて、その方法がわかりません。リンクテキストでも同じものを作りたいです。私は検索してグーグルで検索しましたが、この場合の解決策も例もありません。どんな助けでもありがたいです。
First I should say that the most common way to allow users to edit text in diagrams is to set TextBlock.editable to true and to add a TwoWay Binding of TextBlock.text to some data property. This allows users to edit the text in-place rather than in separate HTML fields.
But it is common to have editing of properties in HTML fields. Assuming there is at least a one way Binding from some data property to the TextBlock.text property in your node, your textarea's blur (or change?) event handler just needs to call Model.setDataProperty within a transaction. Read more about modifying models and transactions.
最後に、ユーザーが編集できるようにするプロパティが多数ある場合、特にプロパティの数が異なる可能性がある場合は、GoJSDataInspectorを使用することをお勧めします。これは、Org ChartEditorサンプルとDataInspectorサンプルによって示されています。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加