Skip to content

Commit

Permalink
[DataGrid] Pass reason to onPaginationModelChange (@DungTiger) (#15402
Browse files Browse the repository at this point in the history
)

Co-authored-by: DungTiger <[email protected]>
Co-authored-by: Bilal Shafi <[email protected]>
  • Loading branch information
3 people authored Nov 18, 2024
1 parent 6dc86ef commit e430b20
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,20 @@ export const useGridPaginationModel = (
}
logger.debug("Setting 'paginationModel' to", paginationModel);

apiRef.current.setState((state) => ({
...state,
pagination: {
...state.pagination,
paginationModel: getDerivedPaginationModel(
state.pagination,
props.signature,
paginationModel,
),
},
}));
apiRef.current.setState(
(state) => ({
...state,
pagination: {
...state.pagination,
paginationModel: getDerivedPaginationModel(
state.pagination,
props.signature,
paginationModel,
),
},
}),
'setPaginationModel',
);
},
[apiRef, logger, props.signature],
);
Expand Down Expand Up @@ -184,17 +187,20 @@ export const useGridPaginationModel = (
...context.stateToRestore.pagination?.paginationModel,
}
: gridPaginationModelSelector(apiRef);
apiRef.current.setState((state) => ({
...state,
pagination: {
...state.pagination,
paginationModel: getDerivedPaginationModel(
state.pagination,
props.signature,
paginationModel,
),
},
}));
apiRef.current.setState(
(state) => ({
...state,
pagination: {
...state.pagination,
paginationModel: getDerivedPaginationModel(
state.pagination,
props.signature,
paginationModel,
),
},
}),
'stateRestorePreProcessing',
);
return params;
},
[apiRef, props.autoPageSize, props.signature],
Expand Down
5 changes: 4 additions & 1 deletion packages/x-data-grid/src/models/props/DataGridProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,10 @@ export interface DataGridPropsWithoutDefaultValue<R extends GridValidRowModel =
* @param {GridPaginationModel} model Updated pagination model.
* @param {GridCallbackDetails} details Additional details for this callback.
*/
onPaginationModelChange?: (model: GridPaginationModel, details: GridCallbackDetails) => void;
onPaginationModelChange?: (
model: GridPaginationModel,
details: GridCallbackDetails<'pagination'>,
) => void;
/**
* Callback fired when the row count has changed.
* @param {number} count Updated row count.
Expand Down

0 comments on commit e430b20

Please sign in to comment.