Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/docs/components/ExampleUseDataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function ExampleUseDataGrid() {
});

useEffect(() => {
dataGrid.filterChanged();
dataGrid.refreshTable();
}, []);

return (
Expand Down
11 changes: 6 additions & 5 deletions packages/react-mui-hooks/hooks/useDataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export type UseDataGridProps = {
*/
export type UseDataGridResponse = {
props: ComponentPropsWithRef<typeof DataGridPro>,
filterChanged: (keepPage?: boolean) => void,
refreshTable: (keepPage?: boolean) => void,
isSelectAll: boolean,
setIsSelectAll: (value: boolean) => void,
isAnySelected: boolean,
Expand Down Expand Up @@ -406,10 +406,11 @@ export function useDataGrid({
}, [pageSize, sortModel, filterModel, onPage, loading]);

/**
* Handles filter changed. This will go back to first page and request page.
* @param keepPage - If set to true, when filter is changed, page will remain selected; returns to first page if set to false.
* Handles the table refresh. This will go back to the first page and request a new one.
*
* @param keepPage - If set to true, when table is refreshed, page will remain selected; returns to first page if set to false.
*/
const handleFilterChanged = (keepPage = false) => {
const handleTableRefresh = (keepPage = false) => {
if (!keepPage) setPageIndex(-1);

handleLoadPage(keepPage ? pageIndex : -1, true);
Expand Down Expand Up @@ -727,7 +728,7 @@ export function useDataGrid({
slotProps,
keepNonExistentRowsSelected
},
filterChanged: handleFilterChanged,
refreshTable: handleTableRefresh,
isSelectAll: isAllItemsSelected,
setIsSelectAll: setIsAllItemsSelected,
isAnySelected: customSelectionModel.length > 0,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-mui-hooks/temp/react-mui-hooks.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export type UseDataGridProps = {
// @public
export type UseDataGridResponse = {
props: ComponentPropsWithRef<typeof DataGridPro>;
filterChanged: (keepPage?: boolean) => void;
refreshTable: (keepPage?: boolean) => void;
isSelectAll: boolean;
setIsSelectAll: (value: boolean) => void;
isAnySelected: boolean;
Expand Down