如何创建一个mxCell,设置其mxGeometry的最小宽度,但如果它比默认宽度高,则会调整为其值字段的html元素的宽度?
现在我有这个代码
var style = 'rounded=0;whiteSpace=wrap;html=1;autosize=1;resizable=0;';
var cell = new mxCell(value, new mxGeometry(0, 0, width, height), style);
但是当我创建这个mxCell时,它的大小总是"width"one_answers"height",即使它包含的html元素(h3标题(超过了mxRectangle。我该怎么解决这个问题?
编辑:谢谢,它使用了graphic.updateCellSize((。由于我想只在必须高于默认值的情况下更改大小,所以我写了以下代码
this.graph.updateCellSize(cell, true);
var geom = cell.getGeometry();
geom.width = geom.width > width ? geom.width : width;
它会更改两次值,这是低效的。我发现了另一种使用getPreferredSizeForCell 的方法
var preferred = this.graph.getPreferredSizeForCell(cell);
var current = cell.getGeometry();
current.width = preferred.width > width ? preferred.width : width;
current.height = preferred.height > height ? preferred.height : height;
试试graph.updateCellSize(cell,true(;