load query data fix

This commit is contained in:
Jan Prochazka
2021-03-10 18:12:30 +01:00
parent a35d5525a3
commit fca23f65de
3 changed files with 20 additions and 6 deletions

View File

@@ -164,7 +164,7 @@
import axios from '../utility/axios'; import axios from '../utility/axios';
import { copyTextToClipboard } from '../utility/clipboard'; import { copyTextToClipboard } from '../utility/clipboard';
export let loadNextData = undefined; export let onLoadNextData = undefined;
export let grider = undefined; export let grider = undefined;
export let display: GridDisplay = undefined; export let display: GridDisplay = undefined;
export let conid = undefined; export let conid = undefined;
@@ -286,6 +286,12 @@
copyTextToClipboard(text); copyTextToClipboard(text);
} }
export function loadNextDataIfNeeded() {
if (onLoadNextData && firstVisibleRowScrollIndex + visibleRowCountUpperBound >= grider.rowCount) {
onLoadNextData();
}
}
$: autofillMarkerCell = $: autofillMarkerCell =
selectedCells && selectedCells.length > 0 && _.uniq(selectedCells.map(x => x[0])).length == 1 selectedCells && selectedCells.length > 0 && _.uniq(selectedCells.map(x => x[0])).length == 1
? [_.max(selectedCells.map(x => x[0])), _.max(selectedCells.map(x => x[1]))] ? [_.max(selectedCells.map(x => x[0])), _.max(selectedCells.map(x => x[1]))]
@@ -326,8 +332,8 @@
$: maxScrollColumn = columnSizes.scrollInView(0, columns.length - 1 - columnSizes.frozenCount, gridScrollAreaWidth); $: maxScrollColumn = columnSizes.scrollInView(0, columns.length - 1 - columnSizes.frozenCount, gridScrollAreaWidth);
$: { $: {
if (loadNextData && firstVisibleRowScrollIndex + visibleRowCountUpperBound >= grider.rowCount) { if (onLoadNextData && firstVisibleRowScrollIndex + visibleRowCountUpperBound >= grider.rowCount && rowHeight > 0) {
loadNextData(); onLoadNextData();
} }
} }

View File

@@ -48,7 +48,7 @@
let changeIndex = 0; let changeIndex = 0;
let rowCountLoaded = null; let rowCountLoaded = null;
const throttleLoadNext = _.throttle(() => domGrid.loadNextData(), 500); const throttleLoadNext = _.throttle(() => domGrid.resetLoadedAll(), 500);
const handleJslDataStats = stats => { const handleJslDataStats = stats => {
if (stats.changeIndex < changeIndex) return; if (stats.changeIndex < changeIndex) return;

View File

@@ -15,15 +15,22 @@
let loadedTime = new Date().getTime(); let loadedTime = new Date().getTime();
let allRowCount = null; let allRowCount = null;
let errorMessage = null; let errorMessage = null;
let domGrid;
const loadNextDataRef = { current: false }; const loadNextDataRef = { current: false };
const loadedTimeRef = { current: null }; const loadedTimeRef = { current: null };
export function resetLoadedAll() {
isLoadedAll = false;
domGrid.loadNextDataIfNeeded();
}
const handleLoadRowCount = async () => { const handleLoadRowCount = async () => {
const rowCount = await loadRowCount($$props); const rowCount = await loadRowCount($$props);
allRowCount = rowCount; allRowCount = rowCount;
}; };
export async function loadNextData() { async function loadNextData() {
if (isLoading) return; if (isLoading) return;
loadNextDataRef.current = false; loadNextDataRef.current = false;
isLoading = true; isLoading = true;
@@ -102,8 +109,9 @@
</script> </script>
<DataGridCore <DataGridCore
bind:this={domGrid}
{...$$props} {...$$props}
loadNextData={handleLoadNextData} onLoadNextData={handleLoadNextData}
{grider} {grider}
{isLoading} {isLoading}
{allRowCount} {allRowCount}