fix: vCell condition issue

This commit is contained in:
Chen Lily 2024-03-04 15:38:04 +08:00
parent 1ed5b39308
commit 4096979d5d

View File

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