From 750a37a27f9e43f8ec242a44194a99e58812779a Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Sun, 13 Mar 2022 11:35:04 +0100 Subject: [PATCH] grid columns display fix --- packages/datalib/src/GridDisplay.ts | 3 ++- packages/web/src/datagrid/DataGridCore.svelte | 1 + packages/web/src/datagrid/SeriesSizes.ts | 3 +++ packages/web/src/datagrid/gridutil.ts | 4 ++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/datalib/src/GridDisplay.ts b/packages/datalib/src/GridDisplay.ts index 7e58fad1..2c566e65 100644 --- a/packages/datalib/src/GridDisplay.ts +++ b/packages/datalib/src/GridDisplay.ts @@ -166,11 +166,12 @@ export abstract class GridDisplay { hideAllColumns() { this.setConfig(cfg => ({ ...cfg, - hiddenColumns: this.columns.map(x => x.uniqueName), + hiddenColumns: this.columns.filter(x => x.uniquePath.length == 1).map(x => x.uniqueName), })); } get hiddenColumnIndexes() { + // console.log('GridDisplay.hiddenColumn', this.config.hiddenColumns); return (this.config.hiddenColumns || []).map(x => _.findIndex(this.allColumns, y => y.uniqueName == x)); } diff --git a/packages/web/src/datagrid/DataGridCore.svelte b/packages/web/src/datagrid/DataGridCore.svelte index bd3cf4b0..ce4bfd48 100644 --- a/packages/web/src/datagrid/DataGridCore.svelte +++ b/packages/web/src/datagrid/DataGridCore.svelte @@ -800,6 +800,7 @@ // $: console.log('containerHeight', containerHeight); // $: console.log('COLUMNS', columns); + // $: console.log('columnSizes.realCount', columnSizes.realCount); // $: console.log('realColumnUniqueNames', realColumnUniqueNames); // $: console.log('columnSizes.realCount', columnSizes.realCount); diff --git a/packages/web/src/datagrid/SeriesSizes.ts b/packages/web/src/datagrid/SeriesSizes.ts index ec62a740..bb2466e6 100644 --- a/packages/web/src/datagrid/SeriesSizes.ts +++ b/packages/web/src/datagrid/SeriesSizes.ts @@ -99,9 +99,12 @@ export class SeriesSizes { } this.modelIndexes = _.range(0, this.count); + // console.log('SeriesSize:build:this.modelIndexes-before', this.modelIndexes); + // console.log('SeriesSize:build:this.hiddenAndFrozenModelIndexes', this.hiddenAndFrozenModelIndexes); if (this.hiddenAndFrozenModelIndexes) { this.modelIndexes = this.modelIndexes.filter(col => !this.hiddenAndFrozenModelIndexes.includes(col)); } + // console.log('SeriesSize:build:this.modelIndexes-result', this.modelIndexes); } public getScrollIndexOnPosition(position: number): number { diff --git a/packages/web/src/datagrid/gridutil.ts b/packages/web/src/datagrid/gridutil.ts index 3b9e26ef..499368d6 100644 --- a/packages/web/src/datagrid/gridutil.ts +++ b/packages/web/src/datagrid/gridutil.ts @@ -17,6 +17,7 @@ export function countColumnSizes(grider: Grider, columns, containerWidth, displa //return this.context.measureText(txt).width; // console.log('countColumnSizes', loadedRows.length, containerWidth); + // console.log('countColumnSizes:columns', columns); columnSizes.maxSize = (containerWidth * 2) / 3; columnSizes.count = columns.length; @@ -114,10 +115,12 @@ export function countVisibleRealColumns(columnSizes, firstVisibleColumnScrollInd ) { visibleRealColumnIndexes.push(colIndex + columnSizes.frozenCount); } + // console.log('countVisibleRealColumns:visibleRealColumnIndexes', visibleRealColumnIndexes); // real columns for (let colIndex of visibleRealColumnIndexes) { let modelColumnIndex = columnSizes.realToModel(colIndex); + // console.log('countVisibleRealColumns:modelColumnIndex', modelColumnIndex); modelIndexes[colIndex] = modelColumnIndex; let col = columns[modelColumnIndex]; @@ -129,6 +132,7 @@ export function countVisibleRealColumns(columnSizes, firstVisibleColumnScrollInd width, }); } + // console.log('countVisibleRealColumns:realColumns', realColumns); return realColumns; }