fix: header z-index issue.

fix: incorrect `onChanged` event trigger on `GridInputColumn`, `GridTextColumn` and `GridDateColumn`.
This commit is contained in:
2024-02-26 16:11:42 +08:00
parent 7940edbea2
commit 38bad864e0
5 changed files with 63 additions and 45 deletions

View File

@ -95,7 +95,7 @@ let r = lang;
* @property {KeyMap<GridSourceItem[]>} source - 下拉数据源缓存对象
* @property {number} __index - 行索引
* @property {number} __offset - 批量删除时暂存的索引偏移量
* @property {KeyMap<boolean>} __editing - 正在编辑
* @property {KeyMap<any>} __editing - 正在编辑的列的原始值字典
* @property {boolean} __changed - 行数据是否发生改变
* @property {boolean} __expanded - 行是否已展开
* @property {GridExpandableObject} __expandable_object - 行扩展对象
@ -2593,19 +2593,30 @@ export class Grid {
const type = isCheckbox ? GridCheckboxColumn : this._var.colTypes[col.key] ?? GridColumn;
let element;
if (!readonly && !isCheckbox && typeof type.createEdit === 'function') {
if (vals.__editing?.[col.key]) {
const oldValue = vals.__editing?.[col.key];
if (oldValue !== undefined) {
delete vals.__editing[col.key];
if (typeof type.leaveEdit === 'function') {
type.leaveEdit(cell.children[0], this._var.el);
}
if (type.editing) {
val = type.getValue({ target: cell.children[0] }, col);
this._onRowChanged(null, i, col, val, cell);
this._onRowChanged(null, i, col, val, cell, oldValue);
}
}
if (stateChanged) {
element = selected ?
type.createEdit(e => this._onRowChanged(e, i, col, type.getValue(e, col), cell), col, this._var.el, vals) :
type.createEdit(e => {
let old;
if (type.editing) {
old = vals.__editing?.[col.key];
if (old === undefined) {
return;
}
delete vals.__editing[col.key];
}
this._onRowChanged(e, i, col, type.getValue(e, col), cell, old);
}, col, this._var.el, vals) :
type.create(col, i, this);
if (typeof col.class === 'string') {
type.setClass(element, col.class);
@ -3783,8 +3794,9 @@ export class Grid {
* @param {GridColumnDefinition} col
* @param {any} value
* @param {HTMLTableCellElement} cell
* @param {any} [oldValue]
*/
_onRowChanged(e, index, col, value, cell) {
_onRowChanged(e, index, col, value, cell, oldValue) {
if (this._var.currentSource == null) {
return;
}
@ -3802,12 +3814,11 @@ export class Grid {
}
if (enabled !== false) {
const val = item[col.key];
let oldValue;
if (val != null && Object.prototype.hasOwnProperty.call(val, 'Value')) {
oldValue = val.Value;
oldValue ??= val.Value;
val.Value = value;
} else {
oldValue = val;
oldValue ??= val;
item[col.key] = value;
}
let tip = col.tooltip;