tiny issue fix.

This commit is contained in:
2023-04-04 23:26:46 +08:00
parent fa1b7df4a0
commit adb74b7441
7 changed files with 130 additions and 27 deletions

View File

@@ -78,8 +78,8 @@ class GridInputColumn extends GridColumn {
const SymbolDropdown = Symbol.for('ui-dropdown');
class GridDropdownColumn extends GridColumn {
static createEdit(trigger) {
const drop = new Dropdown();
static createEdit(trigger, parent) {
const drop = new Dropdown({ parent });
drop.onselected = trigger;
return drop.create();
}
@@ -186,6 +186,10 @@ class GridIconColumn extends GridColumn {
} else {
element.classList.remove('disabled');
}
const tooltip = element.querySelector('.tooltip-wrapper');
if (tooltip != null) {
tooltip.style.display = enabled === false ? 'none' : '';
}
}
}
@@ -463,7 +467,7 @@ class Grid {
width = col.width;
}
if (width > 0) {
this.#changeColumnWidth(i, width);
this.#changeColumnWidth(i, width, true);
}
});
}
@@ -569,7 +573,7 @@ class Grid {
this.#needResize = true;
sizer.innerText = col.caption ?? '';
let width = sizer.offsetWidth + 22;
if (col.allcheck && isCheckbox) {
if (!this.readonly && col.enabled !== false && col.allcheck && isCheckbox) {
width += 32;
}
if (width < MiniColumnWidth) {
@@ -609,7 +613,7 @@ class Grid {
}
const wrapper = document.createElement('div');
th.appendChild(wrapper);
if (col.enabled !== false && col.allcheck && isCheckbox) {
if (!this.readonly && col.enabled !== false && col.allcheck && isCheckbox) {
const check = createCheckbox({
onchange: e => this.#onColumnAllChecked(col, e.target.checked)
});
@@ -832,15 +836,20 @@ class Grid {
let element;
if (!isCheckbox && selectChanged && typeof type.createEdit === 'function') {
element = selected ?
type.createEdit(e => this.#onRowChanged(e, startIndex + i, col, type.getValue(e))) :
type.createEdit(e => this.#onRowChanged(e, startIndex + i, col, type.getValue(e)), this.#refs.bodyContent) :
type.create(col);
cell.replaceChildren(element);
} else {
element = cell.children[0];
}
let enabled = col.enabled;
if (typeof enabled === 'string') {
enabled = item[enabled];
let enabled;
if (this.readonly) {
enabled = false;
} else {
enabled = col.enabled;
if (typeof enabled === 'string') {
enabled = item[enabled];
}
}
type.setValue(element, val, item, col);
if (typeof type.setEnabled === 'function') {
@@ -853,6 +862,7 @@ class Grid {
widths[j] = width;
widths.flag = true;
}
this.#overflows[(startIndex + i) << MaxColumnBit | j] = false;
}
if (typeof col.styleFilter === 'function') {
const style = col.styleFilter(item);
@@ -878,7 +888,7 @@ class Grid {
});
}
#changeColumnWidth(index, width) {
#changeColumnWidth(index, width, keepOverflows) {
const col = this.columns[index];
// const oldwidth = col.width;
const w = `${width}px`;
@@ -903,6 +913,9 @@ class Grid {
// width = this.#refs.bodyContainer.offsetWidth - oldwidth + width;
// this.#refs.bodyContainer.style.width = `${width}px`;
// }
if (keepOverflows) {
return;
}
for (let i = 0; i < this.#currentSource.length; i += 1) {
const keyid = (i << MaxColumnBit) | index;
if (this.#overflows.hasOwnProperty(keyid)) {
@@ -1129,9 +1142,6 @@ class Grid {
delete attr.offset;
});
this.#changeColumnOrder(index);
if (typeof this.columnChanged === 'function') {
this.columnChanged(ColumnChangedType.Reorder, index);
}
}
};
['mousemove', 'mouseup'].forEach(event => window.addEventListener(event, attr[event]));
@@ -1165,7 +1175,7 @@ class Grid {
}
attr.resizing = val;
attr.sizing = true;
this.#changeColumnWidth(index, val);
this.#changeColumnWidth(index, val, true);
};
attr.mousemove = e => throttle(resizemove, RefreshInterval, this, e);
attr.mouseup = e => {