diff --git a/lib/ui/grid/grid.js b/lib/ui/grid/grid.js index ebe4f6f..5d92cbe 100644 --- a/lib/ui/grid/grid.js +++ b/lib/ui/grid/grid.js @@ -1172,6 +1172,10 @@ export class Grid { }; }); this._var.source = list; + this._var.scrollLeft = 0; + if (this._var.el != null) { + this._var.el.scrollLeft = 0; + } this._refreshSource(list); } @@ -1393,7 +1397,7 @@ export class Grid { } else if (this.sortArray?.length > 0) { this.sort(true); } else { - this.resize(true, true); + this.resize(true); } } } @@ -1498,7 +1502,6 @@ export class Grid { if (!keep) { this._var.scrollTop = 0; this._var.el.scrollTop = 0; - this._var.el.scrollLeft = 0; this._var.refs.table.style.top = '0px'; } this._adjustRows(this._var.refs.body); @@ -1558,9 +1561,8 @@ export class Grid { /** * 根据当前排序字段进行列排序 * @param {boolean} [reload] - 为 `true` 则在列排序后调用 [reload]{@linkcode Grid#reload} 方法 - * @param {boolean} [keep] - 重载后是否保持当前滚动位置 */ - sortColumn(reload, keep) { + sortColumn(reload) { const index = this.sortIndex; const col = this.columns[index]; if (col == null) { @@ -1588,7 +1590,7 @@ export class Grid { return; } if (reload) { - this.reload(keep); + this.reload(); } else { this.refresh(); } @@ -1597,9 +1599,8 @@ export class Grid { /** * 根据当前排序列数组进行多列排序 * @param {boolean} [reload] - 为 `true` 则在多列排序后调用 [reload]{@linkcode Grid#reload} 方法 - * @param {boolean} [keep] - 重载后是否保持当前滚动位置 */ - sort(reload, keep) { + sort(reload) { const sortArray = this.sortArray; if (sortArray == null || sortArray.length === 0) { return; @@ -1626,7 +1627,7 @@ export class Grid { return; } if (reload) { - this.reload(keep); + this.reload(); } else { this.refresh(); } @@ -2086,7 +2087,6 @@ export class Grid { * @param {GridItemWrapper[]} [list] */ _refreshSource(list) { - const keep = list == null; list ??= this._var.source; if (this._var.colAttrs.__filtered === true) { this._var.currentSource = list.filter(it => { @@ -2112,16 +2112,15 @@ export class Grid { this._var.selectedIndexes = []; this._var.startIndex = 0; this._var.scrollTop = 0; - this._var.scrollLeft = 0; this._var.rowCount = -1; this.resize(true, false, () => { if (this.sortIndex >= 0) { - this.sortColumn(true, keep); + this.sortColumn(true); } else if (this.sortArray?.length > 0) { - this.sort(true, keep); + this.sort(true); } else { - this.reload(keep); + this.reload(); } }); } @@ -3451,13 +3450,12 @@ export class Grid { } attr.dragging = true; const draggerCellLeft = this._var.refs.header.querySelector('th:last-child').offsetLeft; - // const gridScrollLeft = this._var.el.scrollLeft; let p = this._var.el; let gridLeftFromWindow = p.offsetLeft; while ((p = p.offsetParent) != null) { gridLeftFromWindow += p.offsetLeft + p.clientLeft; } - const mouse = cx - e.currentTarget.offsetLeft + this._var.el.scrollLeft - gridLeftFromWindow; + const mouse = cx - e.currentTarget.offsetLeft + this._var.scrollLeft - gridLeftFromWindow; const dragmove = e => { const cx2 = getClientX(e); const offset = cx2 - cx;