sync
This commit is contained in:
@ -1431,12 +1431,21 @@ export class Grid {
|
||||
e.stopPropagation();
|
||||
}
|
||||
});
|
||||
grid.addEventListener('mousedown', e => {
|
||||
grid.addEventListener('mousedown', async e => {
|
||||
if (e.target === this._var.el) {
|
||||
if (e.offsetX < 0 || e.offsetX > e.target.clientWidth || e.offsetY < 0 || e.offsetY > e.target.clientHeight) {
|
||||
// except scroll bars
|
||||
return;
|
||||
}
|
||||
if (typeof this.willSelect === 'function') {
|
||||
let result = this.willSelect(-1, -1);
|
||||
if (result instanceof Promise) {
|
||||
result = await result;
|
||||
}
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// cancel selections
|
||||
const selectedIndexes = this._var.selectedIndexes;
|
||||
if (selectedIndexes?.length > 0) {
|
||||
@ -1525,7 +1534,7 @@ export class Grid {
|
||||
holder.classList.remove('active');
|
||||
this._clearHolder(holder);
|
||||
}
|
||||
return this._onRowClicked(e, row, col);
|
||||
this._onRowClicked(e, row, col);
|
||||
});
|
||||
holder.addEventListener('dblclick', e => this._onRowDblClicked(e));
|
||||
wrapper.appendChild(holder);
|
||||
@ -2107,6 +2116,7 @@ export class Grid {
|
||||
// FIXME: 清除缓存会导致选中状态下动态数据源下拉列表显示为空
|
||||
// delete it.source;
|
||||
it.values = item;
|
||||
this._var.colAttrs.__filtered = false;
|
||||
if (this.sortArray?.length > 0) {
|
||||
this.sort();
|
||||
} else if (this.sortIndex >= 0) {
|
||||
@ -2148,6 +2158,7 @@ export class Grid {
|
||||
this._var.source.push(newIt);
|
||||
}
|
||||
}
|
||||
this._var.colAttrs.__filtered = false;
|
||||
if (this.sortArray?.length > 0) {
|
||||
this.sort(true);
|
||||
} else if (this.sortIndex >= 0) {
|
||||
@ -2195,6 +2206,7 @@ export class Grid {
|
||||
this._var.source.push(...items);
|
||||
}
|
||||
}
|
||||
this._var.colAttrs.__filtered = false;
|
||||
if (this.sortArray?.length > 0) {
|
||||
this.sort(true);
|
||||
} else if (this.sortIndex >= 0) {
|
||||
@ -3926,6 +3938,8 @@ export class Grid {
|
||||
return String(displayValue).toLowerCase().includes(key);
|
||||
});
|
||||
this._fillFilterList(col, itemlist, items, itemall);
|
||||
this._set(col.key, 'filterTop', -1);
|
||||
itemlist.dispatchEvent(new Event('scroll'));
|
||||
});
|
||||
}
|
||||
// function
|
||||
@ -4405,12 +4419,9 @@ export class Grid {
|
||||
* @param {number} index
|
||||
* @param {number} colIndex
|
||||
*/
|
||||
_onRowClicked(e, index, colIndex) {
|
||||
_afterRowChanged(e, index, colIndex) {
|
||||
const startIndex = this._var.startIndex;
|
||||
const selectedIndex = startIndex + index;
|
||||
if (typeof this.willSelect === 'function' && !this.willSelect(selectedIndex, colIndex)) {
|
||||
return;
|
||||
}
|
||||
// multi-select
|
||||
let flag = false;
|
||||
const selectedIndexes = this._var.selectedIndexes;
|
||||
@ -4471,6 +4482,26 @@ export class Grid {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {MouseEvent} e
|
||||
* @param {number} index
|
||||
* @param {number} colIndex
|
||||
*/
|
||||
async _onRowClicked(e, index, colIndex) {
|
||||
if (typeof this.willSelect === 'function') {
|
||||
const selectedIndex = this._var.startIndex + index;
|
||||
let result = this.willSelect(selectedIndex, colIndex);
|
||||
if (result instanceof Promise) {
|
||||
result = await result;
|
||||
}
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this._afterRowChanged(e, index, colIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @param {MouseEvent} e
|
||||
|
Reference in New Issue
Block a user