nxhoang
November 15, 2018, 9:07am
#1
I want to add a new table.
I tried this but not working:
function createTable(){
//alert("Hello world");
console.log(myDiagram.model.Ce);
const l1 = {
"key": 5,
"category": "TableC8",
"name": "Line 5",
"guests": {},
"loc": "564.5 423.5"
};
myDiagram.model.Ce.push(l1);
myDiagram.requestUpdate(true);
}
walter
November 15, 2018, 11:39am
#2
As clearly stated in GoJS Introduction -- Northwoods Software , your code must not refer to any of the minimized properties – it must only use the official API at GoJS API or at https://gojs.net/latest/release/go.d.ts .
Also, as stated in GoJS Using Models -- Northwoods Software , you cannot modify data without calling Model methods. Otherwise there is no way for the model to know that anything has changed, and thus there is no way for any diagram to know that its model has changed.
1 Like
nxhoang
November 16, 2018, 1:21am
#3
Thanks you,
I use addNodeData. It works now.
function createTable(){
//alert("Hello world");
console.log(myDiagram.model.Ce);
const l1 = {
"key": 5,
"category": "TableC8",
"name": "Line 5",
"guests": {},
"loc": "564.5 423.5"
};
myDiagram.model.addNodeData(l1);
//myDiagram.requestUpdate(true);
}
walter
November 16, 2018, 1:26am
#4
By the way, you should perform all changes within a transaction: GoJS Transactions -- Northwoods Software
The end of the transaction will make sure everything is updated.