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

View File

@ -21,10 +21,21 @@
let jslid;
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;
}
function handleRefresh() {
jslid = null;
loadData(conid, database, sql)
}
const quickExportHandlerRef = createQuickExportHandlerRef();
$: loadData(conid, database, sql);
@ -32,7 +43,7 @@
<ToolStripContainer>
{#if jslid}
<JslDataGrid {jslid} listenInitializeFile />
<JslDataGrid {jslid} listenInitializeFile onCustomGridRefresh={handleRefresh} focusOnVisible />
{:else}
<LoadingInfo message="Loading data..." />
{/if}