gojs如何新增删除和tablerow行?
网友回复
通过addArrayItem实现,完整示例代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>GoJS Table Example</title>
<script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/go.js"></script>
<style>
#myDiagramDiv {
width: 400px;
height: 300px;
border: 1px solid black;
}
button {
margin: 5px;
}
</style>
</head>
<body>
<div id="myDiagramDiv"></div>
<button onclick="addRow()">Add Row</button>
<button onclick="deleteRow()">Delete Row</button>
<script>
function init() {
const $ = go.GraphObject.make;
// 创建 Diagram
const myDiagram = $(go.Diagram, "myDiagramDiv", {
initialContentAlignment: go.Spot.Center,
"undoManager.isEnabled": true
});
// 定义节点模板
myDiagram.nodeTemplate =
$(go.Node, "Auto",
$(go.Shape, { fill: "white" }),
$(go.Panel, "Vertical",
$(go.Panel, "Table",
new go.Binding("itemArray", "items"),
{
defaultRowSeparatorStroke: "black",
...点击查看剩余70%


