query data refresh

This commit is contained in:
Jan Prochazka 2022-03-20 11:47:28 +01:00
parent 5df0204450
commit f10f863940
2 changed files with 22 additions and 4 deletions

View File

@ -9,7 +9,7 @@
toolbar: true, toolbar: true,
isRelatedToTab: true, isRelatedToTab: true,
icon: 'icon reload', icon: 'icon reload',
testEnabled: () => getCurrentDataGrid()?.getDisplay()?.supportsReload, testEnabled: () => getCurrentDataGrid()?.canRefresh(),
onClick: () => getCurrentDataGrid().refresh(), onClick: () => getCurrentDataGrid().refresh(),
}); });
@ -334,6 +334,7 @@
export let collapsedLeftColumnStore; export let collapsedLeftColumnStore;
export let multipleGridsOnTab = false; export let multipleGridsOnTab = false;
export let tabControlHiddenTab = false; export let tabControlHiddenTab = false;
export let onCustomGridRefresh;
// export let generalAllowSave = false; // export let generalAllowSave = false;
export const activator = createActivator('DataGridCore', false); export const activator = createActivator('DataGridCore', false);
@ -362,7 +363,13 @@
const tabid = getContext('tabid'); const tabid = getContext('tabid');
export function refresh() { export function refresh() {
display.reload(); if (onCustomGridRefresh) onCustomGridRefresh();
else display.reload();
}
export function canRefresh() {
if (onCustomGridRefresh) return true;
return getDisplay()?.supportsReload;
} }
export function getGrider() { export function getGrider() {

View File

@ -21,10 +21,21 @@
let jslid; let jslid;
async function loadData(conid, database, sql) { async function loadData(conid, database, sql) {
const resp = await apiCall('sessions/execute-reader', { conid, database, sql, appFolder: schemaName, queryName: pureName }); const resp = await apiCall('sessions/execute-reader', {
conid,
database,
sql,
appFolder: schemaName,
queryName: pureName,
});
jslid = resp.jslid; jslid = resp.jslid;
} }
function handleRefresh() {
jslid = null;
loadData(conid, database, sql)
}
const quickExportHandlerRef = createQuickExportHandlerRef(); const quickExportHandlerRef = createQuickExportHandlerRef();
$: loadData(conid, database, sql); $: loadData(conid, database, sql);
@ -32,7 +43,7 @@
<ToolStripContainer> <ToolStripContainer>
{#if jslid} {#if jslid}
<JslDataGrid {jslid} listenInitializeFile /> <JslDataGrid {jslid} listenInitializeFile onCustomGridRefresh={handleRefresh} focusOnVisible />
{:else} {:else}
<LoadingInfo message="Loading data..." /> <LoadingInfo message="Loading data..." />
{/if} {/if}