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

View File

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

View File

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

View File

@@ -39,7 +39,7 @@
<div class="content-container">
{#each _.compact(tabs) as tab, index}
<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 == 0}<slot name="0" />
{:else if tab.slot == 1}<slot name="1" />

View File

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