More pagination options; don't make pagination count flash

This commit is contained in:
2022-09-13 13:21:41 -05:00
parent ea869c01a0
commit 43095d39df

View File

@ -240,7 +240,6 @@ function EntityList({table}: Props): JSX.Element
setLatestQueryId(thisQueryId); setLatestQueryId(thisQueryId);
console.log(`Issuing query: ${thisQueryId}`); console.log(`Issuing query: ${thisQueryId}`);
setTotalRecords(null);
qController.count(tableName, qFilter).then((count) => qController.count(tableName, qFilter).then((count) =>
{ {
countResults[thisQueryId] = count; countResults[thisQueryId] = count;
@ -687,7 +686,7 @@ function EntityList({table}: Props): JSX.Element
component="div" component="div"
count={totalRecords} count={totalRecords}
page={pageNumber} page={pageNumber}
rowsPerPageOptions={[10, 25, 50]} rowsPerPageOptions={[10, 25, 50, 100, 250]}
rowsPerPage={rowsPerPage} rowsPerPage={rowsPerPage}
onPageChange={(event, value) => handlePageChange(value)} onPageChange={(event, value) => handlePageChange(value)}
onRowsPerPageChange={(event) => handleRowsPerPageChange(Number(event.target.value))} onRowsPerPageChange={(event) => handleRowsPerPageChange(Number(event.target.value))}
@ -782,11 +781,25 @@ function EntityList({table}: Props): JSX.Element
</Menu> </Menu>
); );
///////////////////////////////////////////////////////////////////////////////////////////
// for changes in table controls that don't change the count, call to update the table - //
// but without clearing out totalRecords (so pagination doesn't flash) //
///////////////////////////////////////////////////////////////////////////////////////////
useEffect(() => useEffect(() =>
{ {
setLoading(true); setLoading(true);
updateTable(); updateTable();
}, [pageNumber, rowsPerPage, tableState, columnSortModel, filterModel]); }, [pageNumber, rowsPerPage, columnSortModel]);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
// for state changes that DO change the filter, call to update the table - and DO clear out the totalRecords //
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
useEffect(() =>
{
setLoading(true);
updateTable();
setTotalRecords(null);
}, [tableState, filterModel]);
useEffect(() => useEffect(() =>
{ {