Skip to content
59 changes: 59 additions & 0 deletions docs/data/data-grid/localization/PaginationNumberFormatting.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import * as React from 'react';
import { useDemoData } from '@mui/x-data-grid-generator';
import { DataGridPro } from '@mui/x-data-grid-pro';
import { frFR as locale } from '@mui/x-data-grid/locales';

const LOCALE = 'fr-FR'; // replace with your locale

const formatNumber = (value) => {
if (typeof Intl !== 'undefined' && Intl.NumberFormat) {
try {
const result = new Intl.NumberFormat(LOCALE).format(Number(value));
return result === 'NaN' ? String(value) : result;
} catch {
return String(value);
}
}
return String(value);
};

const paginationDisplayedRows = ({ from, to, count, estimated }) => {
if (!estimated) {
return `${formatNumber(from)}–${formatNumber(to)} sur ${
count !== -1 ? formatNumber(count) : `plus de ${formatNumber(to)}`
}`;
}
const estimatedLabel =
estimated && estimated > to
? `environ ${formatNumber(estimated)}`
: `plus de ${formatNumber(to)}`;
return `${formatNumber(from)}–${formatNumber(to)} sur ${
count !== -1 ? formatNumber(count) : estimatedLabel
}`;
};

const localeText = {
...locale.components.MuiDataGrid.defaultProps.localeText,
paginationDisplayedRows,
};

export default function PaginationNumberFormatting() {
const { data } = useDemoData({
dataSet: 'Commodity',
rowLength: 4,
maxColumns: 6,
});
return (
<div style={{ height: 400, width: '100%' }}>
<DataGridPro
{...data}
pagination
paginationMode="server"
pageSizeOptions={[10000, 20000]}
paginationModel={{ page: 1, pageSize: 10000 }}
rowCount={1000000}
localeText={localeText}
/>
</div>
);
}
69 changes: 69 additions & 0 deletions docs/data/data-grid/localization/PaginationNumberFormatting.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import * as React from 'react';
import { useDemoData } from '@mui/x-data-grid-generator';
import { DataGridPro } from '@mui/x-data-grid-pro';
import { frFR as locale } from '@mui/x-data-grid/locales';

const LOCALE = 'fr-FR'; // replace with your locale

const formatNumber = (value: number | string): string => {
if (typeof Intl !== 'undefined' && Intl.NumberFormat) {
try {
const result = new Intl.NumberFormat(LOCALE).format(Number(value));
return result === 'NaN' ? String(value) : result;
} catch {
return String(value);
}
}
return String(value);
};

const paginationDisplayedRows = ({
from,
to,
count,
estimated,
}: {
from: number;
to: number;
count: number;
estimated?: number;
}) => {
if (!estimated) {
return `${formatNumber(from)}${formatNumber(to)} sur ${
count !== -1 ? formatNumber(count) : `plus de ${formatNumber(to)}`
}`;
}
const estimatedLabel =
estimated && estimated > to
? `environ ${formatNumber(estimated)}`
: `plus de ${formatNumber(to)}`;
return `${formatNumber(from)}${formatNumber(to)} sur ${
count !== -1 ? formatNumber(count) : estimatedLabel
}`;
};

const localeText = {
...locale.components.MuiDataGrid.defaultProps.localeText,
paginationDisplayedRows,
};

export default function PaginationNumberFormatting() {
const { data } = useDemoData({
dataSet: 'Commodity',
rowLength: 4,
maxColumns: 6,
});
return (
<div style={{ height: 400, width: '100%' }}>
<DataGridPro
{...data}
pagination
paginationMode="server"
pageSizeOptions={[10000, 20000]}
paginationModel={{ page: 1, pageSize: 10000 }}
rowCount={1000000}
localeText={localeText}
/>
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<DataGridPro
{...data}
pagination
paginationMode="server"
pageSizeOptions={[10000, 20000]}
paginationModel={{ page: 1, pageSize: 10000 }}
rowCount={1000000}
localeText={localeText}
/>
80 changes: 61 additions & 19 deletions docs/data/data-grid/localization/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,6 @@ In the following example, the label of the quick filter placeholder is customize

{{"demo": "CustomLocaleTextGrid.js", "bg": "inline"}}

:::warning
It's important to note that because the Data Grid uses components from the Material UI library, some translation keys need to be accessed using that component key.

One example is the table pagination component used in the Data Grid footer when pagination is enabled. All the keys provided to the `MuiTablePagination` object are applied as props directly to the [Table Pagination](/material-ui/api/table-pagination/) component.

```jsx
<DataGrid
{...data}
localeText={{
MuiTablePagination: {
labelDisplayedRows: ({ from, to, count }) =>
`${from} - ${to} of ${count === -1 ? `more than ${to}` : count}`,
},
}}
/>
```

:::

## Locale text

The default locale of MUI X is English (United States).
Expand Down Expand Up @@ -114,6 +95,67 @@ The example below demonstrates how to use an RTL language (Arabic) with the Data

{{"demo": "DataGridRTL.js", "bg": "inline"}}

## Pagination number formatting

To format large numbers in the pagination component, customize the `paginationDisplayedRows` with the following code:

```jsx
import { DataGridPro } from '@mui/x-data-grid-pro';
Copy link
Member

@oliviertassinari oliviertassinari Aug 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We must always use the version that matches the docs context when we can, by default MIT.

Suggested change
import { DataGridPro } from '@mui/x-data-grid-pro';
import { DataGrid } from '@mui/x-data-grid';

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DataGrid won't work in this case because the pagination is not allowed to be more than 100.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add this info at the beginning of the section

Copy link
Member

@oliviertassinari oliviertassinari Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DataGrid won't work in this case because the pagination is not allowed to be more than 100.

This would be news for me. People can paginate without limits in the MIT version. Let's remove the Pro component usage.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michelengelen just want to confirm with you before merging this PR. Do you think it make sense for this section to target DataGrid Pro and above (given the error from the image above)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would make sense, yes, but... we do support more than 100 rows in the MIT data grid. This change would then not apply to the pageSize, but rather the currently viewed range of rows and the total rows:

Screenshot 2025-08-21 at 13 50 21

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I think it's better to switch to the community version. Let me update the demo.


// ======================================================
// TODO: replace with your locale
import { frFR as locale } from '@mui/x-data-grid/locales';
const LOCALE = 'fr-FR';
// ======================================================

const formatNumber = (value: number | string): string => {
if (typeof Intl !== 'undefined' && Intl.NumberFormat) {
try {
const result = new Intl.NumberFormat(LOCALE).format(Number(value));
return result === 'NaN' ? value : result;
} catch {
return value;
}
}
return value;
};

const paginationDisplayedRows = ({
from,
to,
count,
estimated,
}: {
from: number;
to: number;
count: number;
page: number;
estimated?: number;
}) => {
if (!estimated) {
return `${formatNumber(from)}–${formatNumber(to)} sur ${
count !== -1 ? formatNumber(count) : `plus de ${formatNumber(to)}`
}`;
}
const estimatedLabel =
estimated && estimated > to
? `environ ${formatNumber(estimated)}`
: `plus de ${formatNumber(to)}`;
return `${formatNumber(from)}–${formatNumber(to)} sur ${
count !== -1 ? formatNumber(count) : estimatedLabel
}`;
};

locale.components.MuiDataGrid.defaultProps.localeText.paginationDisplayedRows =
paginationDisplayedRows;

<DataGridPro
localeText={locale.components.MuiDataGrid.defaultProps.localeText}
/>
```

{{"demo": "PaginationNumberFormatting.js", "bg": "inline"}}

## API

- [DataGrid](/x/api/data-grid/data-grid/)
Expand Down