From 4bfba2ec02128063465dda1ae78cc702e74129d6 Mon Sep 17 00:00:00 2001 From: Jan Prochazka Date: Fri, 5 Mar 2021 17:47:07 +0100 Subject: [PATCH] datagrid --- packages/web/public/dimensions.css | 2 +- packages/web/src/datagrid/DataGridCore.svelte | 80 ++++++++++++++++--- .../src/datagrid/LoadingDataGridCore.svelte | 25 +++--- packages/web/src/widgets/LoadingInfo.svelte | 4 +- 4 files changed, 87 insertions(+), 24 deletions(-) diff --git a/packages/web/public/dimensions.css b/packages/web/public/dimensions.css index 4d0c9248..cef75b50 100644 --- a/packages/web/public/dimensions.css +++ b/packages/web/public/dimensions.css @@ -1,5 +1,5 @@ :root { - --dim-widget-icon-size: 50px; + --dim-widget-icon-size: 60px; --dim-statusbar-height: 20px; --dim-left-panel-width: 300px; --dim-tabs-panel-height: 53px; diff --git a/packages/web/src/datagrid/DataGridCore.svelte b/packages/web/src/datagrid/DataGridCore.svelte index a60e3350..94ce6afb 100644 --- a/packages/web/src/datagrid/DataGridCore.svelte +++ b/packages/web/src/datagrid/DataGridCore.svelte @@ -11,6 +11,30 @@ enabledStore: derived([currentDataGrid], ([grid]) => grid != null), onClick: () => get(currentDataGrid).refresh(), }); + + function getRowCountInfo(selectedCells, grider, realColumnUniqueNames, selectedRowData, allRowCount) { + if (selectedCells.length > 1 && selectedCells.every(x => _.isNumber(x[0]) && _.isNumber(x[1]))) { + let sum = _.sumBy(selectedCells, cell => { + const row = grider.getRowData(cell[0]); + if (row) { + const colName = realColumnUniqueNames[cell[1]]; + if (colName) { + const data = row[colName]; + if (!data) return 0; + let num = +data; + if (_.isNaN(num)) return 0; + return num; + } + } + return 0; + }); + let count = selectedCells.length; + let rowCount = selectedRowData.length; + return `Rows: ${rowCount.toLocaleString()}, Count: ${count.toLocaleString()}, Sum:${sum.toLocaleString()}`; + } + if (allRowCount == null) return 'Loading row count...'; + return `Rows: ${allRowCount.toLocaleString()}`; + }
@@ -250,16 +299,18 @@ {#each _.range(firstVisibleRowScrollIndex, firstVisibleRowScrollIndex + visibleRowCountUpperBound) as rowIndex (rowIndex)} - + {#if rowIndex < grider.rowCount} + + {/if} {/each} @@ -277,6 +328,15 @@ on:scroll={e => (firstVisibleRowScrollIndex = e.detail)} bind:this={domVerticalScroll} /> + {#if allRowCount} +
+ {getRowCountInfo(selectedCells, grider, realColumnUniqueNames, getSelectedRowData(), allRowCount)} +
+ {/if} + + {#if isLoading} + + {/if}