This commit is contained in:
2023-04-28 15:06:47 +08:00
parent 58de68a878
commit 9bf9e7da27
6 changed files with 64 additions and 48 deletions

View File

@ -296,7 +296,7 @@ class Grid {
let height = this.height;
if (height === 0) {
height = this.#containerHeight;
height = this.#containerHeight ??= this.containerHeight;
} else if (isNaN(height) || height < 0) {
height = this.#el.offsetHeight - top;
}
@ -308,12 +308,16 @@ class Grid {
this.#bodyClientWidth = body.clientWidth;
}
reload() {
get containerHeight() {
let length = this.#currentSource.length;
if (this.extraRows > 0) {
length += this.extraRows;
}
this.#containerHeight = length * (this.rowHeight + 1);
return length * (this.rowHeight + 1);
}
reload() {
this.#containerHeight = this.containerHeight;
this.#refs.body.scrollTop = 0;
this.#refs.body.scrollLeft = 0;
this.#refs.bodyContent.style.top = '0px';
@ -634,7 +638,7 @@ class Grid {
}
}
if (Grid.ColumnTypes.isCheckbox(col.type)) {
cell.appendChild(GridCheckboxColumn.createEdit(e => this.#onRowChanged(e, exists + i, col, e.target.checked)));
cell.appendChild(GridCheckboxColumn.createEdit(e => this.#onRowChanged(e, index, col, e.target.checked)));
// this.#colTypes[col.key] = GridCheckboxColumn;
} else {
let type = this.#colTypes[col.key];
@ -1532,7 +1536,7 @@ class Grid {
if (this.#currentSource == null) {
return;
}
const row = this.#currentSource[this.#startIndex + index];
const row = this.#currentSource[index];
const item = row.values;
if (item == null) {
return;