grid row count shows in status bar

This commit is contained in:
Jan Prochazka
2021-11-21 12:00:56 +01:00
parent 13030defc1
commit bb56c01b55
5 changed files with 31 additions and 7 deletions

View File

@@ -176,7 +176,7 @@
onClick: () => getCurrentDataGrid().openChartFromSelection(), onClick: () => getCurrentDataGrid().openChartFromSelection(),
}); });
function getRowCountInfo(selectedCells, grider, realColumnUniqueNames, selectedRowData, allRowCount) { function getSelectedCellsInfo(selectedCells, grider, realColumnUniqueNames, selectedRowData) {
if (selectedCells.length > 1 && selectedCells.every(x => _.isNumber(x[0]) && _.isNumber(x[1]))) { if (selectedCells.length > 1 && selectedCells.every(x => _.isNumber(x[0]) && _.isNumber(x[1]))) {
let sum = _.sumBy(selectedCells, cell => { let sum = _.sumBy(selectedCells, cell => {
const row = grider.getRowData(cell[0]); const row = grider.getRowData(cell[0]);
@@ -196,8 +196,7 @@
let rowCount = selectedRowData.length; let rowCount = selectedRowData.length;
return `Rows: ${rowCount.toLocaleString()}, Count: ${count.toLocaleString()}, Sum:${sum.toLocaleString()}`; return `Rows: ${rowCount.toLocaleString()}, Count: ${count.toLocaleString()}, Sum:${sum.toLocaleString()}`;
} }
if (allRowCount == null) return 'Loading row count...'; return null;
return `Rows: ${allRowCount.toLocaleString()}`;
} }
</script> </script>
@@ -249,6 +248,7 @@
import CollapseButton from './CollapseButton.svelte'; import CollapseButton from './CollapseButton.svelte';
import GenerateSqlFromDataModal from '../modals/GenerateSqlFromDataModal.svelte'; import GenerateSqlFromDataModal from '../modals/GenerateSqlFromDataModal.svelte';
import { showModal } from '../modals/modalTools'; import { showModal } from '../modals/modalTools';
import { updateStatuBarInfo } from '../widgets/StatusBar.svelte';
export let onLoadNextData = undefined; export let onLoadNextData = undefined;
export let grider = undefined; export let grider = undefined;
@@ -271,6 +271,8 @@
export let isDynamicStructure = false; export let isDynamicStructure = false;
export let selectedCellsPublished = () => []; export let selectedCellsPublished = () => [];
export let collapsedLeftColumnStore; export let collapsedLeftColumnStore;
export let multipleGridsOnTab = false;
export let tabControlHiddenTab = false;
// export let generalAllowSave = false; // export let generalAllowSave = false;
export const activator = createActivator('DataGridCore', false); export const activator = createActivator('DataGridCore', false);
@@ -296,6 +298,8 @@
let autofillSelectedCells = emptyCellArray; let autofillSelectedCells = emptyCellArray;
const domFilterControlsRef = createRef({}); const domFilterControlsRef = createRef({});
const tabid = getContext('tabid');
export function refresh() { export function refresh() {
display.reload(); display.reload();
} }
@@ -606,6 +610,8 @@
columns columns
); );
$: selectedCellsInfo = getSelectedCellsInfo(selectedCells, grider, realColumnUniqueNames, getSelectedRowData());
// $: console.log('visibleRealColumns', visibleRealColumns); // $: console.log('visibleRealColumns', visibleRealColumns);
// $: console.log('visibleRowCountUpperBound', visibleRowCountUpperBound); // $: console.log('visibleRowCountUpperBound', visibleRowCountUpperBound);
// $: console.log('rowHeight', rowHeight); // $: console.log('rowHeight', rowHeight);
@@ -1189,6 +1195,16 @@
}, },
]; ];
} }
$: {
if (!tabControlHiddenTab) {
if (!multipleGridsOnTab && allRowCount != null) {
updateStatuBarInfo(tabid, [{ text: `Rows: ${allRowCount.toLocaleString()}` }]);
} else {
updateStatuBarInfo(tabid, []);
}
}
}
</script> </script>
{#if !display || (!isDynamicStructure && (!columns || columns.length == 0))} {#if !display || (!isDynamicStructure && (!columns || columns.length == 0))}
@@ -1355,9 +1371,13 @@
on:scroll={e => (firstVisibleRowScrollIndex = e.detail)} on:scroll={e => (firstVisibleRowScrollIndex = e.detail)}
bind:this={domVerticalScroll} bind:this={domVerticalScroll}
/> />
{#if allRowCount} {#if selectedCellsInfo}
<div class="row-count-label"> <div class="row-count-label">
{getRowCountInfo(selectedCells, grider, realColumnUniqueNames, getSelectedRowData(), allRowCount)} {selectedCellsInfo}
</div>
{:else if allRowCount != null && multipleGridsOnTab}
<div class="row-count-label">
Rows: {allRowCount.toLocaleString()}
</div> </div>
{/if} {/if}

View File

@@ -27,6 +27,7 @@
{#key jslid} {#key jslid}
<DataGrid <DataGrid
{...$$restProps}
{display} {display}
{jslid} {jslid}
gridCoreComponent={JslDataGridCore} gridCoreComponent={JslDataGridCore}

View File

@@ -41,6 +41,7 @@
export let cache; export let cache;
export let setCache; export let setCache;
export let multipleGridsOnTab = false;
$: connection = useConnectionInfo({ conid }); $: connection = useConnectionInfo({ conid });
$: dbinfo = useDatabaseInfo({ conid, database }); $: dbinfo = useDatabaseInfo({ conid, database });
@@ -157,6 +158,7 @@
onRunMacro={handleRunMacro} onRunMacro={handleRunMacro}
macroCondition={macro => macro.type == 'transformValue'} macroCondition={macro => macro.type == 'transformValue'}
onReferenceSourceChanged={reference ? handleReferenceSourceChanged : null} onReferenceSourceChanged={reference ? handleReferenceSourceChanged : null}
multipleGridsOnTab={multipleGridsOnTab || !!reference}
onReferenceClick={value => { onReferenceClick={value => {
if (value && value.referenceId && reference && reference.referenceId == value.referenceId) { if (value && value.referenceId && reference && reference.referenceId == value.referenceId) {
// reference not changed // reference not changed
@@ -181,6 +183,7 @@
setCache={childCache.update} setCache={childCache.update}
masterLoadedTime={myLoadedTime} masterLoadedTime={myLoadedTime}
isDetailView isDetailView
multipleGridsOnTab
/> />
{/key} {/key}
</div> </div>

View File

@@ -39,7 +39,7 @@
<div class="content-container"> <div class="content-container">
{#each _.compact(tabs) as tab, index} {#each _.compact(tabs) as tab, index}
<div class="container" class:isInline class:tabVisible={index == value}> <div class="container" class:isInline class:tabVisible={index == value}>
<svelte:component this={tab.component} {...tab.props} /> <svelte:component this={tab.component} {...tab.props} tabControlHiddenTab={index != value} />
{#if tab.slot != null} {#if tab.slot != null}
{#if tab.slot == 0}<slot name="0" /> {#if tab.slot == 0}<slot name="0" />
{:else if tab.slot == 1}<slot name="1" /> {:else if tab.slot == 1}<slot name="1" />

View File

@@ -12,7 +12,7 @@
> >
{#each resultInfos as info} {#each resultInfos as info}
<div class="wrapper"> <div class="wrapper">
<JslDataGrid jslid={info.jslid} /> <JslDataGrid jslid={info.jslid} multipleGridsOnTab={resultInfos.length >= 2} />
</div> </div>
{/each} {/each}
</div> </div>