From 1083111c95e3343332272c6a9804f0749f40e6af Mon Sep 17 00:00:00 2001 From: tobiu Date: Tue, 14 Jan 2025 12:10:48 +0100 Subject: [PATCH] grid.Container: columns_: add support for run-time changes #6217 --- src/container/Base.mjs | 2 ++ src/grid/Container.mjs | 4 ++-- src/grid/header/Toolbar.mjs | 32 ++------------------------------ 3 files changed, 6 insertions(+), 32 deletions(-) diff --git a/src/container/Base.mjs b/src/container/Base.mjs index 5e3147422..58f7ae2cc 100644 --- a/src/container/Base.mjs +++ b/src/container/Base.mjs @@ -395,6 +395,8 @@ class Container extends Component { itemsRoot.cn.push(vdom) }); + // We need to add items into the vdom + me.updateDepth = -1; me.update() } diff --git a/src/grid/Container.mjs b/src/grid/Container.mjs index d0e3f2c66..de4b0d391 100644 --- a/src/grid/Container.mjs +++ b/src/grid/Container.mjs @@ -222,7 +222,7 @@ class GridContainer extends BaseContainer { * @protected */ afterSetColumns(value, oldValue) { - if (Array.isArray(oldValue) && oldValue.length > 0) { + if (oldValue?.length > 0) { let me = this, {headerToolbar} = me; @@ -231,7 +231,7 @@ class GridContainer extends BaseContainer { headerToolbar.createItems() } - me.view?.createViewData(me.store.items) + me.view?.createViewData() } } diff --git a/src/grid/header/Toolbar.mjs b/src/grid/header/Toolbar.mjs index 38887505f..8055cdd70 100644 --- a/src/grid/header/Toolbar.mjs +++ b/src/grid/header/Toolbar.mjs @@ -112,10 +112,7 @@ class Toolbar extends BaseToolbar { super.createItems(); - let dockLeftWidth = 0, - dockRightWidth = 0, - {items} = me, - len = items.length, + let {items} = me, style; items.forEach((item, index) => { @@ -128,31 +125,8 @@ class Toolbar extends BaseToolbar { if (item.minWidth) {style.minWidth = item.minWidth + 'px'} if (item.width) {style.width = item.width + 'px'} - if (item.dock) { - NeoArray.add(item.vdom.cls, 'neo-locked'); - - /*if (item.dock === 'left') { - style.left = dockLeftWidth + 'px' - } - - dockLeftWidth += (item.width + 1) // todo: borders fix - */ - } - item.sortable = me.sortable; - item.wrapperStyle = style; - - // inverse loop direction - item = items[len - index -1]; - - /*if (item.dock === 'right') { - style = item.wrapperStyle; - style.right = dockRightWidth + 'px'; - - item.wrapperStyle = style; - - dockRightWidth += (item.width + 1) // todo: borders fix - }*/ + item.wrapperStyle = style }); me.update() @@ -172,8 +146,6 @@ class Toolbar extends BaseToolbar { return null } - - /** * @param {Boolean} silent=false * @returns {Promise}