From 54d4c4c4c09244ced65f3c410ab15aaefbcae7d6 Mon Sep 17 00:00:00 2001 From: Tsanie Lily Date: Tue, 25 Apr 2023 17:33:27 +0800 Subject: [PATCH] start vtable mode --- lib/ui/grid/column.js | 21 ++++++++++++++++----- lib/ui/grid/grid.js | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/ui/grid/column.js b/lib/ui/grid/column.js index 9a38fea..690157d 100644 --- a/lib/ui/grid/column.js +++ b/lib/ui/grid/column.js @@ -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 { diff --git a/lib/ui/grid/grid.js b/lib/ui/grid/grid.js index 7b9a525..35beb90 100644 --- a/lib/ui/grid/grid.js +++ b/lib/ui/grid/grid.js @@ -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); });