Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
@mui/x-data-grid
Advanced tools
@mui/x-data-grid is a powerful data grid component for building complex and feature-rich data tables in React applications. It is part of the Material-UI (MUI) library and provides a wide range of functionalities such as sorting, filtering, pagination, and more.
Basic Data Grid
This code demonstrates a basic data grid with columns and rows. It includes features like pagination and checkbox selection.
import * as React from 'react';
import { DataGrid } from '@mui/x-data-grid';
const columns = [
{ field: 'id', headerName: 'ID', width: 90 },
{ field: 'firstName', headerName: 'First name', width: 150 },
{ field: 'lastName', headerName: 'Last name', width: 150 },
{ field: 'age', headerName: 'Age', type: 'number', width: 110 },
{ field: 'fullName', headerName: 'Full name', description: 'This column has a value getter and is not sortable.', sortable: false, width: 160, valueGetter: (params) => `${params.row.firstName || ''} ${params.row.lastName || ''}`, },
];
const rows = [
{ id: 1, lastName: 'Snow', firstName: 'Jon', age: 35 },
{ id: 2, lastName: 'Lannister', firstName: 'Cersei', age: 42 },
{ id: 3, lastName: 'Lannister', firstName: 'Jaime', age: 45 },
{ id: 4, lastName: 'Stark', firstName: 'Arya', age: 16 },
{ id: 5, lastName: 'Targaryen', firstName: 'Daenerys', age: null },
{ id: 6, lastName: 'Melisandre', firstName: null, age: 150 },
{ id: 7, lastName: 'Clifford', firstName: 'Ferrara', age: 44 },
{ id: 8, lastName: 'Frances', firstName: 'Rossini', age: 36 },
{ id: 9, lastName: 'Roxie', firstName: 'Harvey', age: 65 },
];
export default function DataTable() {
return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid rows={rows} columns={columns} pageSize={5} checkboxSelection />
</div>
);
}
Sorting and Filtering
This code demonstrates how to enable sorting and filtering in the data grid. The grid can be sorted in ascending or descending order, and it can be filtered based on specific column values.
import * as React from 'react';
import { DataGrid } from '@mui/x-data-grid';
const columns = [
{ field: 'id', headerName: 'ID', width: 90 },
{ field: 'firstName', headerName: 'First name', width: 150 },
{ field: 'lastName', headerName: 'Last name', width: 150 },
{ field: 'age', headerName: 'Age', type: 'number', width: 110 },
{ field: 'fullName', headerName: 'Full name', description: 'This column has a value getter and is not sortable.', sortable: false, width: 160, valueGetter: (params) => `${params.row.firstName || ''} ${params.row.lastName || ''}`, },
];
const rows = [
{ id: 1, lastName: 'Snow', firstName: 'Jon', age: 35 },
{ id: 2, lastName: 'Lannister', firstName: 'Cersei', age: 42 },
{ id: 3, lastName: 'Lannister', firstName: 'Jaime', age: 45 },
{ id: 4, lastName: 'Stark', firstName: 'Arya', age: 16 },
{ id: 5, lastName: 'Targaryen', firstName: 'Daenerys', age: null },
{ id: 6, lastName: 'Melisandre', firstName: null, age: 150 },
{ id: 7, lastName: 'Clifford', firstName: 'Ferrara', age: 44 },
{ id: 8, lastName: 'Frances', firstName: 'Rossini', age: 36 },
{ id: 9, lastName: 'Roxie', firstName: 'Harvey', age: 65 },
];
export default function DataTable() {
return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid rows={rows} columns={columns} pageSize={5} checkboxSelection sortingOrder={['asc', 'desc']} filterModel={{ items: [{ columnField: 'firstName', operatorValue: 'contains', value: 'a' }] }} />
</div>
);
}
Custom Pagination
This code demonstrates how to implement custom pagination in the data grid. Users can select the number of rows to display per page from the provided options.
import * as React from 'react';
import { DataGrid } from '@mui/x-data-grid';
const columns = [
{ field: 'id', headerName: 'ID', width: 90 },
{ field: 'firstName', headerName: 'First name', width: 150 },
{ field: 'lastName', headerName: 'Last name', width: 150 },
{ field: 'age', headerName: 'Age', type: 'number', width: 110 },
{ field: 'fullName', headerName: 'Full name', description: 'This column has a value getter and is not sortable.', sortable: false, width: 160, valueGetter: (params) => `${params.row.firstName || ''} ${params.row.lastName || ''}`, },
];
const rows = [
{ id: 1, lastName: 'Snow', firstName: 'Jon', age: 35 },
{ id: 2, lastName: 'Lannister', firstName: 'Cersei', age: 42 },
{ id: 3, lastName: 'Lannister', firstName: 'Jaime', age: 45 },
{ id: 4, lastName: 'Stark', firstName: 'Arya', age: 16 },
{ id: 5, lastName: 'Targaryen', firstName: 'Daenerys', age: null },
{ id: 6, lastName: 'Melisandre', firstName: null, age: 150 },
{ id: 7, lastName: 'Clifford', firstName: 'Ferrara', age: 44 },
{ id: 8, lastName: 'Frances', firstName: 'Rossini', age: 36 },
{ id: 9, lastName: 'Roxie', firstName: 'Harvey', age: 65 },
];
export default function DataTable() {
return (
<div style={{ height: 400, width: '100%' }}>
<DataGrid rows={rows} columns={columns} pageSize={5} rowsPerPageOptions={[5, 10, 20]} pagination />
</div>
);
}
react-table is a lightweight, fast, and extendable data grid built for React. It provides a hook-based API and is highly customizable. Compared to @mui/x-data-grid, react-table offers more flexibility but requires more manual setup for features like sorting, filtering, and pagination.
ag-grid-react is a feature-rich data grid component for React applications. It offers a wide range of functionalities, including sorting, filtering, and pagination, similar to @mui/x-data-grid. However, ag-grid-react is known for its performance and scalability, making it suitable for large datasets.
react-data-grid is a powerful and customizable data grid component for React. It provides features like sorting, filtering, and pagination out of the box. Compared to @mui/x-data-grid, react-data-grid offers more customization options but may require more effort to integrate with Material-UI.
This package is the Community plan edition of the data grid component. It's part of MUI X, an open-core extension of MUI Core, with advanced components.
Install the package in your project directory with:
npm install @mui/x-data-grid
This component has the following peer dependencies that you will need to install as well.
"peerDependencies": {
"@mui/material": "^5.15.0",
"react": "^17.0.0 || ^18.0.0",
"react-dom": "^17.0.0 || ^18.0.0"
},
Visit https://mui.com/x/react-data-grid/ to view the full documentation.
7.0.0-alpha.9
Jan 19, 2024
We'd like to offer a big thanks to the 11 contributors who made this release possible. Here are some highlights ✨:
SimpleTreeView
customization examples (#11424) @noraleonte@mui/material
peer dependency for all packages (#11692) @LukasTy
The minimum required version of @mui/material
is now 5.15.0
.The ariaV7
experimental flag has been removed and the Data Grid now uses the improved accessibility implementation by default.
If you were using the ariaV7
flag, you can remove it from the experimentalFeatures
prop:
-<DataGrid experimentalFeatures={{ ariaV7: true }} />
+<DataGrid />
The most notable changes that might affect your application or tests are:
The role="grid"
attribute along with related ARIA attributes are now applied to the inner div
element instead of the root div
element:
-<div class="MuiDataGrid-root" role="grid" aria-colcount="5" aria-rowcount="101" aria-multiselectable="false">
+<div class="MuiDataGrid-root">
<div class="MuiDataGrid-toolbarContainer"></div>
- <div class="MuiDataGrid-main"></div>
+ <div class="MuiDataGrid-main" role="grid" aria-colcount="5" aria-rowcount="101" aria-multiselectable="false"></div>
<div class="MuiDataGrid-footerContainer"></div>
</div>
When the Tree data feature is used, the grid role is now role="treegrid"
instead of role="grid"
.
The Data Grid cells now have role="gridcell"
instead of role="cell"
.
The buttons in toolbar composable components GridToolbarColumnsButton
, GridToolbarFilterButton
, GridToolbarDensity
, and GridToolbarExport
are now wrapped with a tooltip component and have a consistent interface. To override some props corresponding to the toolbar buttons or their corresponding tooltips, you can use the slotProps
prop. Following is an example diff. See Toolbar section for more details.
function CustomToolbar() {
return (
<GridToolbarContainer>
<GridToolbarColumnsButton />
<GridToolbarFilterButton
- title="Custom filter" // 🛑 This was previously forwarded to the tooltip component
+ slotProps={{ tooltip: { title: 'Custom filter' } }} // ✅ This is the correct way now
/>
<GridToolbarDensitySelector
- variant="outlined" // 🛑 This was previously forwarded to the button component
+ slotProps={{ button: { variant: 'outlined' } }} // ✅ This is the correct way now
/>
</GridToolbarContainer>
);
}
Column grouping is now enabled by default. The flag columnGrouping
is no longer needed to be passed to the experimentalFeatures
prop to enable it.
-<DataGrid experimentalFeatures={{ columnGrouping: true }} />
+<DataGrid />
The column grouping API methods getColumnGroupPath
and getAllGroupDetails
are no longer prefixed with unstable_
.
The column grouping selectors gridFocusColumnGroupHeaderSelector
and gridTabIndexColumnGroupHeaderSelector
are no longer prefixed with unstable_
.
The disabled column specific features like hiding
, sorting
, filtering
, pinning
, row grouping
, etc could now be controlled programmatically using initialState
, respective controlled models, or the API object. See the related docs section.
FAQs
The Community plan edition of the Data Grid components (MUI X).
The npm package @mui/x-data-grid receives a total of 936,749 weekly downloads. As such, @mui/x-data-grid popularity was classified as popular.
We found that @mui/x-data-grid demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 14 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.