From 799f25862dbd82ef238e7f698c249c5803414b1e Mon Sep 17 00:00:00 2001 From: tobiu Date: Tue, 14 Jan 2025 14:09:04 +0100 Subject: [PATCH] grid.View: createViewData() => opt out, if the store has no items #6224 --- src/grid/View.mjs | 21 +++++++-------------- src/main/DomAccess.mjs | 4 ++-- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/grid/View.mjs b/src/grid/View.mjs index f1082b8cb..2b0fb891d 100644 --- a/src/grid/View.mjs +++ b/src/grid/View.mjs @@ -184,7 +184,7 @@ class GridView extends Component { * @protected */ afterSetAvailableRows(value, oldValue) { - if (value > 0 && this.store.getCount() > 0) { + if (value > 0) { this.createViewData() } } @@ -228,9 +228,7 @@ class GridView extends Component { // for changing an array inline, we need to use the leading underscore me._visibleColumns[1] = value.length - 1; - if (me.store.getCount() > 0) { - me.createViewData() - } + me.createViewData() } } @@ -498,29 +496,24 @@ class GridView extends Component { */ createViewData() { let me = this, - {bufferRowRange, selectedRows, startIndex} = me, + {bufferRowRange, startIndex, store} = me, rows = [], endIndex, i; - if (me.availableRows < 1 || me.columnPositions.length < 1) { + if (store.getCount() < 1 || me.availableRows < 1 || me.columnPositions.length < 1) { return } - endIndex = Math.min(me.store.getCount(), me.availableRows + startIndex + bufferRowRange); + endIndex = Math.min(store.getCount(), me.availableRows + startIndex + bufferRowRange); startIndex = Math.max(0, startIndex - bufferRowRange); for (i=startIndex; i < endIndex; i++) { - rows.push(me.createRow({record: me.store.items[i], rowIndex: i})) + rows.push(me.createRow({record: store.items[i], rowIndex: i})) } me.getVdomRoot().cn = rows; - me.promiseUpdate().then(() => { - if (selectedRows?.length > 0) { - // this logic only works for selection.grid.RowModel - Neo.main.DomAccess.scrollToTableRow({appName: me.appName, id: selectedRows[0]}) - } - }) + me.update() } /** diff --git a/src/main/DomAccess.mjs b/src/main/DomAccess.mjs index e0097db6a..d3a061a3a 100644 --- a/src/main/DomAccess.mjs +++ b/src/main/DomAccess.mjs @@ -11,8 +11,8 @@ const lengthRE = /^\d+\w+$/, capturePassive = { - capture : true, - passive : true + capture: true, + passive: true }, fontSizeProps = [