【发布时间】:2017-12-08 07:00:44
【问题描述】:
我需要动态更改类别值。
代码:
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';
})
), . . .
这工作正常,节点动态改变它的颜色。
但是,这样做之后:
diagram.undoManager.undo();
节点切换到模型中的上一个类别(这没关系),但我没有看到颜色变回以前的颜色。 只有 diagram.rebuildParts() 方法有效,但我不能使用它。
有什么想法吗?
【问题讨论】:
标签: bind categories fill undo gojs