From 618ab2abbcaedc120f32ef9212dd3d9a05cf927c Mon Sep 17 00:00:00 2001 From: tobiu Date: Tue, 7 Jan 2025 17:52:31 +0100 Subject: [PATCH] #6184 grid.View: updateVisibleColumns() --- src/grid/Container.mjs | 2 ++ src/grid/View.mjs | 51 +++++++++++++++++++++++++----------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/src/grid/Container.mjs b/src/grid/Container.mjs index 4e1e2fbd9..0aa7511d9 100644 --- a/src/grid/Container.mjs +++ b/src/grid/Container.mjs @@ -527,6 +527,8 @@ class GridContainer extends BaseContainer { console.log(this.mounted, data); await me.passSizeToView(true); + me.view.updateVisibleColumns(); + me.headerToolbar.passSizeToView() } diff --git a/src/grid/View.mjs b/src/grid/View.mjs index e46832bfa..13ba42bd1 100644 --- a/src/grid/View.mjs +++ b/src/grid/View.mjs @@ -258,28 +258,10 @@ class GridView extends Component { * @protected */ afterSetScrollPosition(value, oldValue) { - let me = this, - countColumnPositions = me.columnPositions.length; - - if (value.x !== oldValue?.x && countColumnPositions > 0) { - let i = 0, - endIndex = countColumnPositions - 1, - column, startIndex; - - for (; i < countColumnPositions; i++) { - column = me.columnPositions[i]; - - if (value.x >= column.x && value.x <= column.x + column.width) { - startIndex = i - } - - if (me.containerWidth + value.x < column.x) { - endIndex = i - 1; - break - } - } + let me = this; - me.visibleColumns = [startIndex, endIndex] + if (value.x !== oldValue?.x && me.columnPositions.length > 0) { + me.updateVisibleColumns() } if (value.y !== oldValue?.y) { @@ -792,6 +774,33 @@ class GridView extends Component { me.update() } } + + /** + * + */ + updateVisibleColumns() { + let me = this, + {x} = me.scrollPosition, + i = 0, + len = me.columnPositions.length, + endIndex = len - 1, + column, startIndex; + + for (; i < len; i++) { + column = me.columnPositions[i]; + + if (x >= column.x && x <= column.x + column.width) { + startIndex = i + } + + if (me.containerWidth + x < column.x) { + endIndex = i - 1; + break + } + } + + me.visibleColumns = [startIndex, endIndex] + } } export default Neo.setupClass(GridView);