【问题标题】:GoJS undo a change of category property that is binding to the shape fill propertyGoJS 撤消绑定到形状填充属性的类别属性更改
【发布时间】: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


    【解决方案1】:

    类别(模板)是特殊的。在更改节点类别时尝试使用Model.setCategoryForNodeData

    如果您不更改节点模板,请选择与“类别”不同的数据属性名称,因为它在 GoJS 模型中具有其他含义。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-08-20
      • 1970-01-01
      • 2017-06-27
      • 1970-01-01
      • 2010-11-26
      相关资源
      最近更新 更多