![](/img/trans.png)
[英]How can I get the row value when edit any text in row of scrolling table in Gojs?
[英]How can I delete a row from a Scrolling Table in Gojs?
我正在Gojs中使用滾動表在兩個表的行之間繪制鏈接(假設輸入和輸出表)。 輸入表和輸出表都是使用Gojs中的滾動表功能繪制的。
現在,我想從“輸出”表中刪除一行,但是從技術上講,我沒有找到任何方法來執行此操作,因為每個表都充當一個Gojs節點,並且當我單擊一行時,它會選擇整個表(節點)而不是該特定行。
這是我的代碼:
var nodeJson;
var $ = go.GraphObject.make;
var inputFieldTable = [
{ ID: "001", Name: "Input 1", Text: "Err1" },
{ ID: "002", Name: "Input 2", Text: "Err2" },
{ ID: "003", Name: "Input 3", Text: "Err3" },
{ ID: "004", Name: "Input 4", Text: "Err4" },
{ ID: "005", Name: "Input 5", Text: "Err5" },
{ ID: "006", Name: "Input 6", Text: "Err6" },
{ ID: "007", Name: "Input 7", Text: "Err7" }
];
var outputFieldTable = [
{ ID: "101", Name: "Output 1", Text: "Integer" },
{ ID: "102", Name: "Output 2", Text: "Integer" },
{ ID: "103", Name: "Output 3", Text: "Integer" },
{ ID: "104", Name: "Output 4", Text: "String" },
{ ID: "105", Name: "Output 5", Text: "String" },
{ ID: "106", Name: "Output 6", Text: "Double" },
{ ID: "107", Name: "Output 7", Text: "Multivalue" }
];
myDiagram =
$(go.Diagram, "myDiagramDiv",
{
initialContentAlignment: go.Spot.Center,
"undoManager.isEnabled": true,
allowMove: false,
allowDelete: true,
allowCopy: false,
allowDragOut: false,
allowDrop: false
});
myDiagram.nodeTemplate =
$(go.Node, "Vertical",
{
selectionObjectName: "SCROLLING",
resizable: false, resizeObjectName: "SCROLLING",
portSpreading: go.Node.SpreadingNone
},
new go.Binding("location").makeTwoWay(),
$(go.TextBlock,
{ font: "bold 14px sans-serif" },
new go.Binding("text", "key")),
$(go.Panel, "Auto",
$(go.Shape, { fill: "white" }),
$("ScrollingTable",
{ stretch: go.GraphObject.Fill },
new go.Binding("TABLE.itemArray", "items"),
new go.Binding("TABLE.column", "left", function (left) { return left ? 2 : 0; }),
new go.Binding("desiredSize", "size").makeTwoWay(),
{
name: "SCROLLING",
desiredSize: new go.Size(100, 100),
"TABLE.itemTemplate":
$(go.Panel, "TableRow",
{
defaultStretch: go.GraphObject.Horizontal,
fromSpot: go.Spot.LeftRightSides,
toSpot: go.Spot.LeftRightSides,
fromLinkable: true,
toLinkable: true,
//allowDelete: true,
//isGroup: true,
},
new go.Binding("portId", "Name"),
$(go.TextBlock, { column: 1 }, new go.Binding("text", "Name")),
$(go.TextBlock, { column: 2 }, new go.Binding("text", "Text"))
),
"TABLE.defaultColumnSeparatorStroke": "gray",
"TABLE.defaultColumnSeparatorStrokeWidth": 0.5,
"TABLE.defaultRowSeparatorStroke": "gray",
"TABLE.defaultRowSeparatorStrokeWidth": 0.5,
"TABLE.defaultSeparatorPadding": new go.Margin(1, 3, 0, 3)
}
)
)
);
myDiagram.model = $(go.GraphLinksModel,
{
linkFromPortIdProperty: "fromPort",
linkToPortIdProperty: "toPort",
nodeDataArray: [
{
key: "Input", left: true, location: new go.Point(0, 0), size: new go.Size(170, 100),
items: inputFieldTable
},
{
key: "Output", location: new go.Point(300, 0), size: new go.Size(170, 100),
items: outputFieldTable
}
]
});
http://gojs.net/latest/samples/selectableFields.html演示了如何執行此操作。
基本上,您支持突出顯示單個字段並跟蹤節點中突出顯示的字段,從而有效地形成所有突出顯示字段的集合。 然后,您可以重寫CommandHandler.deleteSelection方法以刪除選定的字段(如果有),而不是刪除選定的節點。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.