diff --git a/lib/ui/grid/grid.js b/lib/ui/grid/grid.js index 26fcd09..fb4f3ff 100644 --- a/lib/ui/grid/grid.js +++ b/lib/ui/grid/grid.js @@ -1539,13 +1539,14 @@ export class Grid { /** * 重新填充Grid单元格数据 + * @param {boolean} [force] - 忽略 `value` 的判断进行强制刷新 */ - refresh() { + refresh(force) { if (this._var.refs.body == null) { throw new Error('body has not been created.'); } const widths = {}; - this._fillRows(this._tableRows, this.columns, widths); + this._fillRows(this._tableRows, this.columns, widths, force); if (this._var.needResize && widths.flag) { this._var.needResize = false; this.columns.forEach((col, i) => { @@ -2507,8 +2508,9 @@ export class Grid { * @param {HTMLTableRowElement[]} rows * @param {GridColumnDefinition[]} cols * @param {any} widths + * @param {boolean} [force] */ - _fillRows(rows, cols, widths) { + _fillRows(rows, cols, widths, force) { const startIndex = this._var.startIndex; const selectedIndexes = this._var.selectedIndexes; const offset = this.expandable ? 1 : 0; @@ -2661,13 +2663,20 @@ export class Grid { } else { element = cell.children[0]; } - if (val !== virtualCell.value) { + if (stateChanged) { + if (typeof type.createEdit === 'function') { + delete virtualCell.attrs; + delete virtualCell.style; + delete virtualCell.value; + } + if (typeof type.setEditing === 'function') { + type.setEditing(element, virtualRow.editing); + } + } + if (force || val !== virtualCell.value) { virtualCell.value = val; type.setValue(element, val, vals, col, this); } - if (stateChanged && typeof type.setEditing === 'function') { - type.setEditing(element, virtualRow.editing); - } if (virtualRow.editing && typeof type.setEnabled === 'function') { let enabled; if (readonly) {