必须通过创建一个 setTimeout 来解决这个问题,该 setTimeout 调用一个重复检查大小变化的函数,如下所示(排除了一些不直接相关的代码):
function Datagrid() {
var _this = this; setTimeout(function () { _this.CheckAutoColumns(); }, 20);
}
function Datagrid_CheckAutoColumns() {
if (this != null) {
var render = false;
for (var i = 0; i < this.Columns.length; i++) {
if (this.Columns[i].__LastWidth != this.Columns[i].Container.width()) {
render = true;
break;
}
}
if (render == true) { this.Render(); }
if (this.Disposing === false) { var _this = this; setTimeout(function () { _this.CheckAutoColumns(); }, 20); }
}
}
Datagrid.prototype.constructor = Datagrid;
Datagrid.prototype.CheckAutoColumns = Datagrid_CheckAutoColumns;