From eafaf897e670fb9de2c1bfeda0433fa2c7c353bf Mon Sep 17 00:00:00 2001 From: Darin Kelkhoff Date: Mon, 24 Apr 2023 13:07:36 -0500 Subject: [PATCH] Try again re: not rendering if columns weren't known; change to use local rowIndex, not one from backend --- src/qqq/pages/records/query/RecordQuery.tsx | 19 +++++++------------ src/qqq/utils/DataGridUtils.tsx | 3 ++- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/qqq/pages/records/query/RecordQuery.tsx b/src/qqq/pages/records/query/RecordQuery.tsx index 1aba942..d4c5d34 100644 --- a/src/qqq/pages/records/query/RecordQuery.tsx +++ b/src/qqq/pages/records/query/RecordQuery.tsx @@ -471,6 +471,11 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element linkBase += linkBase.endsWith("/") ? "" : "/"; const columns = DataGridUtils.setupGridColumns(tableMetaData, linkBase); setColumnsModel(columns); + + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // let the next render (since columnsModel is watched below) build the filter, using the new columnsModel (in case of joins) // + /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + return; } ////////////////////////////////////////////////////////////////////////////////////////////////// @@ -535,16 +540,6 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element } } - /////////////////////////////////////////////////////////////////////////////////////////////////////// - // before we can issue the query, we must have the columns model (to figure out if we need to join). // - // so, if we don't have it, then return and let a later call do it. // - /////////////////////////////////////////////////////////////////////////////////////////////////////// - if(!columnsModel || columnsModel.length == 0) - { - console.log("Returning before issuing query, because no columnsModel."); - return; - } - ////////////////////////////////////////////////////////////////////////////////////////////////// // assign a new query id to the query being issued here. then run both the count & query async // // and when they load, store their results associated with this id. // @@ -1575,7 +1570,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element setTotalRecords(null); setDistinctRecords(null); updateTable(); - }, [tableState, filterModel]); + }, [columnsModel, tableState, filterModel]); useEffect(() => { @@ -1692,7 +1687,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element sortingOrder={["asc", "desc"]} sortModel={columnSortModel} getRowClassName={(params) => (params.indexRelativeToCurrentPage % 2 === 0 ? "even" : "odd")} - getRowId={(row) => row.__qRowIndex} + getRowId={(row) => row.__rowIndex} /> diff --git a/src/qqq/utils/DataGridUtils.tsx b/src/qqq/utils/DataGridUtils.tsx index e717f13..f0dfc6c 100644 --- a/src/qqq/utils/DataGridUtils.tsx +++ b/src/qqq/utils/DataGridUtils.tsx @@ -40,10 +40,11 @@ export default class DataGridUtils { const fields = [ ...tableMetaData.fields.values() ]; const rows = [] as any[]; + let rowIndex = 0; results.forEach((record: QRecord) => { const row: any = {}; - row.__qRowIndex = record.values.get("__qRowIndex"); + row.__rowIndex = rowIndex++; fields.forEach((field) => {