fix: error rowIndex when there were expanded rows.
optimize: load
This commit is contained in:
parent
d17abdf4b2
commit
5797c2a9cf
@ -379,6 +379,7 @@ class GridColumnDefinition {
|
|||||||
/**
|
/**
|
||||||
* 大于 0 则设置为该宽度,否则根据列内容自动调整列宽
|
* 大于 0 则设置为该宽度,否则根据列内容自动调整列宽
|
||||||
* @type {number}
|
* @type {number}
|
||||||
|
* @default 50
|
||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
width;
|
width;
|
||||||
@ -750,6 +751,7 @@ const GridColumnDirection = {
|
|||||||
* @property {string} [langs.requirePrompt=All sort criteria must have...]
|
* @property {string} [langs.requirePrompt=All sort criteria must have...]
|
||||||
* @property {string} [langs.duplicatePrompt={column} is being sorted more than once...]
|
* @property {string} [langs.duplicatePrompt={column} is being sorted more than once...]
|
||||||
* @property {number} [virtualCount=100] - 行数大于等于该值则启用虚模式
|
* @property {number} [virtualCount=100] - 行数大于等于该值则启用虚模式
|
||||||
|
* @property {boolean} [autoResize=true] - 未设置宽度的列自动调整列宽
|
||||||
* @property {number} [rowHeight=36] - 表格行高
|
* @property {number} [rowHeight=36] - 表格行高
|
||||||
* @property {number} [lineHeight=24] - 文本行高(多行文本列计算高度时使用)
|
* @property {number} [lineHeight=24] - 文本行高(多行文本列计算高度时使用)
|
||||||
* @property {string} [filterIcon=filter] - 列头过滤图标,旧版本样式(横着三个点)需修改为 `"ellipsis-h"`
|
* @property {string} [filterIcon=filter] - 列头过滤图标,旧版本样式(横着三个点)需修改为 `"ellipsis-h"`
|
||||||
@ -1151,6 +1153,13 @@ export class Grid {
|
|||||||
* @ignore
|
* @ignore
|
||||||
*/
|
*/
|
||||||
virtualCount = 100;
|
virtualCount = 100;
|
||||||
|
/**
|
||||||
|
* 未设置宽度的列自动调整列宽
|
||||||
|
* @type {boolean}
|
||||||
|
* @default true
|
||||||
|
* @ignore
|
||||||
|
*/
|
||||||
|
autoResize = true;
|
||||||
/**
|
/**
|
||||||
* 表格行高
|
* 表格行高
|
||||||
* @type {number}
|
* @type {number}
|
||||||
@ -1431,9 +1440,6 @@ export class Grid {
|
|||||||
*/
|
*/
|
||||||
get source() { return this._var.currentSource?.map(s => s.values) }
|
get source() { return this._var.currentSource?.map(s => s.values) }
|
||||||
set source(list) {
|
set source(list) {
|
||||||
if (this._var.el == null) {
|
|
||||||
throw new Error('grid has not been initialized.')
|
|
||||||
}
|
|
||||||
if (!Array.isArray(list)) {
|
if (!Array.isArray(list)) {
|
||||||
throw new Error('source is not an Array.')
|
throw new Error('source is not an Array.')
|
||||||
}
|
}
|
||||||
@ -1664,7 +1670,7 @@ export class Grid {
|
|||||||
this._var.scrollLeft = 0;
|
this._var.scrollLeft = 0;
|
||||||
this._var.rowCount = -1;
|
this._var.rowCount = -1;
|
||||||
|
|
||||||
this.resize(true, null, () => {
|
this.resize(true, false, () => {
|
||||||
if (this.sortIndex >= 0) {
|
if (this.sortIndex >= 0) {
|
||||||
this.sortColumn(true);
|
this.sortColumn(true);
|
||||||
} else if (this.sortArray?.length > 0) {
|
} else if (this.sortArray?.length > 0) {
|
||||||
@ -1865,7 +1871,7 @@ export class Grid {
|
|||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const rowIndex = parent.classList.contains('ui-grid-total-row') ? -1 : indexOfParent(parent);
|
const rowIndex = parent.classList.contains('ui-grid-total-row') ? -1 : this._tableRows.indexOf(parent);
|
||||||
let colIndex = indexOfParent(target) - (this.expandable ? 1 : 0);
|
let colIndex = indexOfParent(target) - (this.expandable ? 1 : 0);
|
||||||
if (colIndex >= this.columns.length) {
|
if (colIndex >= this.columns.length) {
|
||||||
colIndex = -1;
|
colIndex = -1;
|
||||||
@ -1921,7 +1927,7 @@ export class Grid {
|
|||||||
} else if (this.sortArray?.length > 0) {
|
} else if (this.sortArray?.length > 0) {
|
||||||
this.sort(true);
|
this.sort(true);
|
||||||
} else {
|
} else {
|
||||||
this.reload();
|
this.resize(true, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1955,7 +1961,7 @@ export class Grid {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const body = this._var.refs.body;
|
const body = this._var.refs.body;
|
||||||
const top = this.headerVisible === false ? 0 : this._var.refs.header.offsetHeight;
|
const top = this.headerVisible === false ? 0 : this.rowHeight; // this._var.refs.header.offsetHeight;
|
||||||
|
|
||||||
let height = this.height;
|
let height = this.height;
|
||||||
if (height === 0) {
|
if (height === 0) {
|
||||||
@ -2061,10 +2067,10 @@ export class Grid {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
const children = this._var.refs.table.children;
|
// const children = this._var.refs.table.children;
|
||||||
this._var.headerHeight = children[0].offsetHeight;
|
this._var.headerHeight = this.rowHeight; // children[0].offsetHeight;
|
||||||
if (children.length > 2) {
|
if (this.total != null) {
|
||||||
this._var.footerHeight = children[2].offsetHeight;
|
this._var.footerHeight = this._var.refs.table.children[2].offsetHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2469,8 +2475,11 @@ export class Grid {
|
|||||||
type ??= GridColumn;
|
type ??= GridColumn;
|
||||||
this._var.colTypes[col.key] = type;
|
this._var.colTypes[col.key] = type;
|
||||||
}
|
}
|
||||||
if (col.width > 0 || col.shrink || typeof type.createCaption === 'function') {
|
if (col.width > 0 || col.shrink || !this.autoResize || typeof type.createCaption === 'function') {
|
||||||
// col.autoResize = false;
|
// col.autoResize = false;
|
||||||
|
if (isNaN(col.width) || col.width <= 0) {
|
||||||
|
col.width = 50;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this._set(col.key, 'autoResize', true);
|
this._set(col.key, 'autoResize', true);
|
||||||
this._var.needResize = true;
|
this._var.needResize = true;
|
||||||
@ -3060,7 +3069,7 @@ export class Grid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// footer
|
// footer
|
||||||
const children = this._var.refs.table.children;
|
// const children = this._var.refs.table.children;
|
||||||
const hasTotal = this.total != null;
|
const hasTotal = this.total != null;
|
||||||
if (hasTotal) {
|
if (hasTotal) {
|
||||||
const footerCells = this._footerCells;
|
const footerCells = this._footerCells;
|
||||||
@ -3080,9 +3089,9 @@ export class Grid {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this._var.headerHeight = children[0].offsetHeight;
|
this._var.headerHeight = this.rowHeight; // children[0].offsetHeight;
|
||||||
if (hasTotal) {
|
if (hasTotal) {
|
||||||
this._var.footerHeight = children[2].offsetHeight;
|
this._var.footerHeight = this._var.refs.table.children[2].offsetHeight;
|
||||||
const footerOffset = this._var.refs.table.offsetHeight - this._var.el.clientHeight;
|
const footerOffset = this._var.refs.table.offsetHeight - this._var.el.clientHeight;
|
||||||
if (this._var.footerOffset !== footerOffset) {
|
if (this._var.footerOffset !== footerOffset) {
|
||||||
this._var.footerOffset = footerOffset;
|
this._var.footerOffset = footerOffset;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user