Skip to content

Commit

Permalink
[core] Add hook useGridPagination to call onGridPage and onGridPageSi…
Browse files Browse the repository at this point in the history
…ze (#3880)
  • Loading branch information
flaviendelangle authored Feb 8, 2022
1 parent c350167 commit 2bc8e32
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useGridPageSize } from './useGridPageSize';
import { GridApiRef } from '../../../models/api/gridApiRef';
import { DataGridProcessedProps } from '../../../models/props/DataGridProps';
import { useGridPage } from './useGridPage';

/**
* @requires useGridFilter (state)
* @requires useGridDimensions (event) - can be after
*/
export const useGridPagination = (
apiRef: GridApiRef,
props: Pick<
DataGridProcessedProps,
| 'page'
| 'pageSize'
| 'onPageChange'
| 'onPageSizeChange'
| 'autoPageSize'
| 'rowCount'
| 'initialState'
>,
) => {
useGridPageSize(apiRef, props);
useGridPage(apiRef, props);
};
6 changes: 2 additions & 4 deletions packages/grid/x-data-grid-pro/src/useDataGridProComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import { useGridFocus } from '../../_modules_/grid/hooks/features/focus/useGridF
import { useGridInfiniteLoader } from '../../_modules_/grid/hooks/features/infiniteLoader/useGridInfiniteLoader';
import { useGridKeyboard } from '../../_modules_/grid/hooks/features/keyboard/useGridKeyboard';
import { useGridKeyboardNavigation } from '../../_modules_/grid/hooks/features/keyboard/useGridKeyboardNavigation';
import { useGridPageSize } from '../../_modules_/grid/hooks/features/pagination/useGridPageSize';
import { useGridPage } from '../../_modules_/grid/hooks/features/pagination/useGridPage';
import { useGridPagination } from '../../_modules_/grid/hooks/features/pagination/useGridPagination';
import { useGridPreferencesPanel } from '../../_modules_/grid/hooks/features/preferencesPanel/useGridPreferencesPanel';
import { useGridEditing } from '../../_modules_/grid/hooks/features/editRows/useGridEditing';
import { useGridRows } from '../../_modules_/grid/hooks/features/rows/useGridRows';
Expand Down Expand Up @@ -57,8 +56,7 @@ export const useDataGridProComponent = (
useGridDensity(apiRef, props);
useGridColumnReorder(apiRef, props);
useGridColumnResize(apiRef, props);
useGridPageSize(apiRef, props);
useGridPage(apiRef, props);
useGridPagination(apiRef, props);
useGridRowsMeta(apiRef, props);
useGridScroll(apiRef, props);
useGridInfiniteLoader(apiRef, props);
Expand Down
6 changes: 2 additions & 4 deletions packages/grid/x-data-grid/src/useDataGridComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ import { useGridFilter } from '../../_modules_/grid/hooks/features/filter/useGri
import { useGridFocus } from '../../_modules_/grid/hooks/features/focus/useGridFocus';
import { useGridKeyboard } from '../../_modules_/grid/hooks/features/keyboard/useGridKeyboard';
import { useGridKeyboardNavigation } from '../../_modules_/grid/hooks/features/keyboard/useGridKeyboardNavigation';
import { useGridPageSize } from '../../_modules_/grid/hooks/features/pagination/useGridPageSize';
import { useGridPage } from '../../_modules_/grid/hooks/features/pagination/useGridPage';
import { useGridPagination } from '../../_modules_/grid/hooks/features/pagination/useGridPagination';
import { useGridPreferencesPanel } from '../../_modules_/grid/hooks/features/preferencesPanel/useGridPreferencesPanel';
import { useGridEditing } from '../../_modules_/grid/hooks/features/editRows/useGridEditing';
import { useGridRows } from '../../_modules_/grid/hooks/features/rows/useGridRows';
Expand All @@ -38,8 +37,7 @@ export const useDataGridComponent = (props: DataGridProcessedProps) => {
useGridSorting(apiRef, props);
useGridPreferencesPanel(apiRef, props);
useGridFilter(apiRef, props);
useGridPageSize(apiRef, props);
useGridPage(apiRef, props);
useGridPagination(apiRef, props);
useGridRowsMeta(apiRef, props);
useGridScroll(apiRef, props);
useGridColumnMenu(apiRef);
Expand Down

0 comments on commit 2bc8e32

Please sign in to comment.