start vtable mode

This commit is contained in:
Tsanie Lily 2023-04-25 17:33:27 +08:00
parent 0be2078c45
commit 54d4c4c4c0
2 changed files with 17 additions and 6 deletions

View File

@ -7,9 +7,13 @@ import { setTooltip } from "../tooltip";
import Dropdown from "../dropdown";
class GridColumn {
static create() { return createElement('span') }
static create() {
return createElement('span');
}
static setValue(element, val) { element.innerText = val }
static setValue(element, val) {
element.innerText = val;
}
static setStyle(element, style) {
for (let css of Object.entries(style)) {
@ -49,7 +53,9 @@ class GridInputColumn extends GridColumn {
static getValue(e) { return e.target.value }
static setEnabled(element, enabled) { element.disabled = enabled === false }
static setEnabled(element, enabled) {
element.disabled = enabled === false;
}
}
class GridTextColumn extends GridInputColumn {
@ -79,6 +85,7 @@ class GridTextColumn extends GridInputColumn {
const lines = String(val).split('\n').length;
element.style.height = `${lines * grid.lineHeight + 12}px`;
}
// TODO: bad performance
}
}
}
@ -171,11 +178,15 @@ class GridCheckboxColumn extends GridColumn {
return check;
}
static setValue(element, val) { element.querySelector('input').checked = val }
static setValue(element, val) {
element.querySelector('input').checked = val;
}
static getValue(e) { return e.target.checked }
static setEnabled(element, enabled) { element.querySelector('input').disabled = enabled === false }
static setEnabled(element, enabled) {
element.querySelector('input').disabled = enabled === false;
}
}
class GridIconColumn extends GridColumn {

View File

@ -67,6 +67,7 @@ class Grid {
#scrollLeft;
#colTypes = {};
#colAttrs = {};
#vtable = [];
columns = [];
langs = {
@ -629,7 +630,6 @@ class Grid {
}
cell.appendChild(type.create(col));
}
}
row.appendChild(cell);
});