Try again re: not rendering if columns weren't known; change to use local rowIndex, not one from backend

This commit is contained in:
2023-04-24 13:07:36 -05:00
parent 472fb03ed0
commit eafaf897e6
2 changed files with 9 additions and 13 deletions

View File

@ -471,6 +471,11 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
linkBase += linkBase.endsWith("/") ? "" : "/"; linkBase += linkBase.endsWith("/") ? "" : "/";
const columns = DataGridUtils.setupGridColumns(tableMetaData, linkBase); const columns = DataGridUtils.setupGridColumns(tableMetaData, linkBase);
setColumnsModel(columns); 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 // // 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. // // and when they load, store their results associated with this id. //
@ -1575,7 +1570,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
setTotalRecords(null); setTotalRecords(null);
setDistinctRecords(null); setDistinctRecords(null);
updateTable(); updateTable();
}, [tableState, filterModel]); }, [columnsModel, tableState, filterModel]);
useEffect(() => useEffect(() =>
{ {
@ -1692,7 +1687,7 @@ function RecordQuery({table, launchProcess}: Props): JSX.Element
sortingOrder={["asc", "desc"]} sortingOrder={["asc", "desc"]}
sortModel={columnSortModel} sortModel={columnSortModel}
getRowClassName={(params) => (params.indexRelativeToCurrentPage % 2 === 0 ? "even" : "odd")} getRowClassName={(params) => (params.indexRelativeToCurrentPage % 2 === 0 ? "even" : "odd")}
getRowId={(row) => row.__qRowIndex} getRowId={(row) => row.__rowIndex}
/> />
</Box> </Box>
</Card> </Card>

View File

@ -40,10 +40,11 @@ export default class DataGridUtils
{ {
const fields = [ ...tableMetaData.fields.values() ]; const fields = [ ...tableMetaData.fields.values() ];
const rows = [] as any[]; const rows = [] as any[];
let rowIndex = 0;
results.forEach((record: QRecord) => results.forEach((record: QRecord) =>
{ {
const row: any = {}; const row: any = {};
row.__qRowIndex = record.values.get("__qRowIndex"); row.__rowIndex = rowIndex++;
fields.forEach((field) => fields.forEach((field) =>
{ {