1
我需要以非常的方式更改类别值。GoJS撤销绑定到形状填充属性的类别属性的更改
代码:
diagram.startTransaction('changing state: ' + node.data.text);
model.setDataProperty(node.data, 'category', 'stateInitial');
diagram.commitTransaction('changing state: ' + node.data.text);
节点模板:
$(go.Shape, 'RoundedRectangle',
{ stroke: null , strokeWidth: 0 },
new go.Binding("fill", "category", function(category){
if(category == 'stateInitial'){
return '#99AE3B';
}
else if(category == 'stateFinal'){
return '#E53935';
}
return '#6699CC';
})
), . . .
该工程确定,该节点dinamcally改变其颜色。
但是,这样做后:
diagram.undoManager.undo();
节点交换机到模型中的一个类别(这是确定),但我看不出颜色的变回以前的颜色。 只有diagram.rebuildParts()方法有效,但我无法使用它。
有什么想法?