Migration from v5 to v6
This guide describes the changes needed to migrate the Data Grid from v5 to v6.
Start using the alpha release
In package.json, change the version of the data grid package to next.
-"@mui/x-data-grid": "latest",
+"@mui/x-data-grid": "next",
Using next ensures that it will always use the latest v6 alpha release, but you can also use a fixed version, like 6.0.0-alpha.0.
Breaking changes
Since v6 is a major release, it contains some changes that affect the public API. These changes were done for consistency, improve stability and make room for new features. Below are described the steps you need to make to migrate from v5 to v6.
Renamed props
To avoid confusion with the props that will be added for the cell selection feature, some props related to row selection were renamed to have "row" in their name. The renamed props are the following:
Old name New name selectionModelrowSelectionModelonSelectionModelChangeonRowSelectionModelChangedisableSelectionOnClickdisableRowSelectionOnClickdisableMultipleSelectiondisableMultipleRowSelectionshowCellRightBordershowCellVerticalBordershowColumnRightBordershowColumnVerticalBorder
Removed props
- The
disableIgnoreModificationsIfProcessingPropsprop was removed and its behavior whentruewas incorporated as the default behavior. The old behavior can be restored by usingapiRef.current.stopRowEditMode({ ignoreModifications: true })orapiRef.current.stopCellEditMode({ ignoreModifications: true }). - The
onColumnVisibilityChangeprop was removed. UseonColumnVisibilityModelChangeinstead. - The
components.Headerslot was removed. Usecomponents.Toolbarslot instead.
State access
- The
gridSelectionStateSelectorselector was renamed togridRowSelectionStateSelector. - The
gridColumnsSelectorselector was removed. Use more specific grid columns selectors instead. - The
allGridColumnsFieldsSelectorselector was removed. UsegridColumnFieldsSelectorinstead. - The
allGridColumnsSelectorselector was removed. UsegridColumnDefinitionsSelectorinstead. - The
visibleGridColumnsSelectorselector was removed. UsegridVisibleColumnDefinitionsSelectorinstead. - The
filterableGridColumnsSelectorselector was removed. UsegridFilterableColumnDefinitionsSelectorinstead. - The
filterableGridColumnsIdsSelectorselector was removed. UsegridFilterableColumnLookupSelectorinstead. - The
visibleGridColumnsLengthSelectorselector was removed. UsegridVisibleColumnDefinitionsSelectorinstead. - The
gridColumnsMetaSelectorselector was removed. UsegridColumnsTotalWidthSelectororgridColumnPositionsSelectorinstead. - The
getGridNumericColumnOperatorsselector was removed. UsegetGridNumericOperatorsinstead. - The
gridVisibleRowsSelectorselector was removed. UsegridVisibleSortedRowIdsSelectorinstead. - The
gridRowGroupingStateSelectorselector was removed. - The
gridFilterStateSelectorselector was removed. - The
gridRowsStateSelectorselector was removed. - The
gridSortingStateSelectorselector was removed. - The
gridTotalHeaderHeightSelectorselector was removed. - The
gridDensityRowHeightSelectorselector was removed. - The
gridDensityHeaderHeightSelectorselector was removed. - The
apiRef.current.state.density.headerHeightproperty was removed. - The
apiRef.current.state.density.rowHeightproperty was removed.
Events
- The
selectionChangeevent was renamed torowSelectionChange. - The
rowsScrollevent was renamed toscrollPositionChange. - The
columnVisibilityChangeevent was removed. UsecolumnVisibilityModelChangeinstead. - The
cellNavigationKeyDownevent was removed. UsecellKeyDownand check the key provided in the event argument. - The
columnHeaderNavigationKeyDownevent was removed. UsecolumnHeaderKeyDownand check the key provided in the event argument. - The
GridCallbackDetails['api']was removed from event details. Use theapiRefreturned byuseGridApiContextoruseGridApiRefinstead.
Columns
The
GridColDef['hide']property was removed. UseGridColDef['columnVisibility']instead.Returning
nullincolumn.renderCellorcolumn.renderEditCellnow renders an empty cell instead of the default formatted value. To fall back to the default formatted value, returnundefinedinstead ofnull.const renderCell = () => { if (condition) { return <CustomComponent />; } - return null; + return undefined; }
Column menu
The column menu components have been renamed or merged with the new design for consistency and API improvement, the new components are following:
Old name New name GridFilterMenuItemGridColumnMenuFilterItemHideGridColMenuItemGridColumnMenuHideItemGridColumnsMenuItemGridColumnMenuColumnsItemSortGridMenuItemsGridColumnMenuSortItemGridColumnPinningMenuItemsGridColumnMenuPinningItemGridAggregationColumnMenuItemGridColumnMenuAggregationItemGridRowGroupingColumnMenuItems,GridRowGroupableColumnMenuItemsGridColumnMenuGroupingItemGridFilterItemPropshas been renamed toGridColumnMenuItemProps.Props
columnandcurrentColumnpassed toGridColumnMenuand column menu items have been renamed tocolDef
Rows
- The
GridRowParams['getValue']property was removed. Useparams.rowinstead. - The
GridCellParams['getValue']property was removed. Useparams.rowinstead. - The
GridActionsCellProps['api']property was removed. UseuseGridApiContexthook instead to getapiRef. - The
GridActionsCellProps['getValue']property was removed. Useparams.rowinstead. - The
GridFooterCellProps['getValue']property was removed. Useparams.rowinstead.
apiRef methods
The
apiRef.current.updateColumnmethod was removed. UseapiRef.current.updateColumnsinstead.The
apiRef.current.getColumnsMetamethod was removed. UsegridColumnsTotalWidthSelectororgridColumnPositionsSelectorselectors instead.The
apiRef.current.getRowIndexmethod was removed. UseapiRef.current.getRowIndexRelativeToVisibleRowsinstead.The
apiRef.current.setDensitysignature was changed. It only acceptsdensity: GridDensityas a single parameter.Some internal undocumented
apiRefmethods and properties were removed.If you don't use undocumented properties - you can skip the list below. Otherwise, please check the list and open an issue if there's something missing in the
apiRef.List of removed undocumented methods and properties
getLoggerwindowReffooterRefheaderRefcolumnHeadersElementRefcolumnHeadersContainerElementRefunstable_cachesunstable_eventManagerunstable_requestPipeProcessorsApplicationunstable_registerPipeProcessorunstable_registerPipeApplierunstable_storeDetailPanelHeightunstable_detailPanelHasAutoHeightunstable_calculateColSpanunstable_rowHasAutoHeightunstable_getLastMeasuredRowIndexunstable_getViewportPageSizeunstable_updateGridDimensionsRefunstable_getRenderContextunstable_registerStrategyProcessorunstable_applyStrategyProcessorunstable_getActiveStrategyunstable_setStrategyAvailabilityunstable_setCellEditingEditCellValueunstable_getRowWithUpdatedValuesFromCellEditingunstable_setRowEditingEditCellValueunstable_getRowWithUpdatedValuesFromRowEditingunstable_runPendingEditCellValueMutationunstable_moveFocusToRelativeCellunstable_updateControlStateunstable_registerControlState
Filtering
- The
GridFilterItem['columnField']was renamed toGridFilterItem['field'] - The
GridFilterItem['operatorValue']was renamed toGridFilterItem['operator'] - The
GridFilterItem['operator']is now required.
Other exports
The
useGridApihook was removed. UseapiRef.currentinstead.The
useGridStatehook was removed. UseapiRef.current.state,apiRef.current.setStateandapiRef.current.forceUpdateinstead.The
getGridColDefutility function was removed.The
GridColumnstype was removed. UseGridColDef[]instead.The
GridActionsColDefinterface was removed. UseGridColDefinstead.The
GridEnrichedColDeftype was removed. UseGridColDefinstead.The
GridStateColDeftype was removed.The
GridDensityTypesenum was removed. UseGridDensitytype instead.If you use it to type
searchPredicate- useGridColumnsPanelProps['searchPredicate']instead.If you use it to type
getApplyFilterFn- useGridFilterOperator['getApplyFilterFn']instead.The
GridHeaderPlaceholdercomponent was removed.The
GridValueGetterFullParamstype was removed.The
GridSortModelParamsinterface was removed.The
GridApiReftype was removed. UseReact.MutableRefObject<GridApi>instead.The
GridCellValuetype was removed. Useanyor theVgeneric passed to most interfaces.The
GridRowDatatype was removed. UseGridRowModelinstead.The
filterPanelOperatorstranslation key was renamed tofilterPanelOperatorThe
MAX_PAGE_SIZEconstant was removed.The
DATA_GRID_DEFAULT_SLOTS_COMPONENTSexport was removed.The
useGridScrollFnhook was removed.
CSS classes
Some CSS classes were removed or renamed
MUI X v5 classes MUI X v6 classes Note .MuiDataGrid-withBorder.MuiDataGrid-withBorderColorThe class only sets border-colorCSS property