@@ -274,6 +274,9 @@ export function DashAgGrid(props) {
274274 const [ openGroups , setOpenGroups ] = useState ( { } ) ;
275275 const [ columnState_push , setColumnState_push ] = useState ( true ) ;
276276 const [ rowTransactionState , setRowTransactionState ] = useState ( null ) ;
277+ const resettingCount = useRef ( false ) ;
278+ const prevRowCountRef = useRef ( null ) ;
279+ const resetTimeoutRef = useRef ( null ) ;
277280
278281 const components = useMemo (
279282 ( ) => ( {
@@ -841,9 +844,11 @@ export function DashAgGrid(props) {
841844 return {
842845 getRows ( params ) {
843846 getRowsParams . current = params ;
847+ if ( resettingCount . current ) {
848+ return ;
849+ }
844850 customSetProps ( { getRowsRequest : params } ) ;
845851 } ,
846-
847852 destroy ( ) {
848853 getRowsParams . current = null ;
849854 } ,
@@ -1408,13 +1413,50 @@ export function DashAgGrid(props) {
14081413 }
14091414 } , [ props . id ] ) ;
14101415
1411- // Handle infinite scrolling datasource
1416+ // handle getRowsResponse
14121417 useEffect ( ( ) => {
1413- if ( isDatasourceLoadedForInfiniteScrolling ( ) ) {
1418+ if ( isDatasourceLoadedForInfiniteScrolling ( ) && getRowsParams . current ) {
1419+ const params = getRowsParams . current ;
1420+
14141421 const { rowData, rowCount} = props . getRowsResponse ;
1415- getRowsParams . current . successCallback ( rowData , rowCount ) ;
1422+
1423+ // If we were previously at 0 rows, tell ag‑Grid the new count first,
1424+ // then defer the successCallback so ag‑Grid has processed setRowCount.
1425+ // This avoids an edge case where ag‑Grid ignores the successCallback because it thinks the
1426+ // request is already fulfilled, since the row count is >0, but then doesn't render any rows
1427+ // because it hasn't processed the new row count yet.
1428+ // We do not use purge, reset on the cache or datasource refresh here,
1429+ // since those would trigger a new getRows request, which we do not want since we already have the new data
1430+ // and just need to get ag‑Grid to process the new row count and render it.
1431+ if (
1432+ prevRowCountRef . current !== null &&
1433+ prevRowCountRef . current === 0
1434+ ) {
1435+ resettingCount . current = true ;
1436+ params . api . setRowCount ( rowCount , false ) ;
1437+
1438+ resetTimeoutRef . current = setTimeout ( ( ) => {
1439+ resettingCount . current = false ;
1440+ const p = getRowsParams . current ;
1441+ if ( p ) {
1442+ p . successCallback ( rowData , rowCount ) ;
1443+ }
1444+ } , 0 ) ;
1445+ } else {
1446+ params . successCallback ( rowData , rowCount ) ;
1447+ }
1448+
1449+ prevRowCountRef . current = rowCount ;
14161450 customSetProps ( { getRowsResponse : null } ) ;
14171451 }
1452+
1453+ return ( ) => {
1454+ if ( resetTimeoutRef . current ) {
1455+ clearTimeout ( resetTimeoutRef . current ) ;
1456+ resetTimeoutRef . current = null ;
1457+ }
1458+ resettingCount . current = false ;
1459+ } ;
14181460 } , [ props . getRowsResponse ] ) ;
14191461
14201462 // Handle master detail response
0 commit comments