Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
ag-grid-react
Advanced tools
ag-grid-react is a powerful and feature-rich data grid component for React applications. It provides a wide range of functionalities for displaying, editing, and managing data in a tabular format. It is highly customizable and supports large datasets, making it suitable for enterprise-level applications.
Basic Grid Setup
This code sets up a basic grid with three columns: Make, Model, and Price. It also provides some sample row data to display in the grid.
import React from 'react';
import { AgGridReact } from 'ag-grid-react';
import 'ag-grid-community/styles/ag-grid.css';
import 'ag-grid-community/styles/ag-theme-alpine.css';
const App = () => {
const columnDefs = [
{ headerName: 'Make', field: 'make' },
{ headerName: 'Model', field: 'model' },
{ headerName: 'Price', field: 'price' }
];
const rowData = [
{ make: 'Toyota', model: 'Celica', price: 35000 },
{ make: 'Ford', model: 'Mondeo', price: 32000 },
{ make: 'Porsche', model: 'Boxster', price: 72000 }
];
return (
<div className="ag-theme-alpine" style={{ height: 400, width: 600 }}>
<AgGridReact
columnDefs={columnDefs}
rowData={rowData}
/>
</div>
);
};
export default App;
Sorting and Filtering
This code demonstrates how to enable sorting and filtering on the columns of the grid. Users can click on the column headers to sort and use the filter input to filter the data.
import React from 'react';
import { AgGridReact } from 'ag-grid-react';
import 'ag-grid-community/styles/ag-grid.css';
import 'ag-grid-community/styles/ag-theme-alpine.css';
const App = () => {
const columnDefs = [
{ headerName: 'Make', field: 'make', sortable: true, filter: true },
{ headerName: 'Model', field: 'model', sortable: true, filter: true },
{ headerName: 'Price', field: 'price', sortable: true, filter: true }
];
const rowData = [
{ make: 'Toyota', model: 'Celica', price: 35000 },
{ make: 'Ford', model: 'Mondeo', price: 32000 },
{ make: 'Porsche', model: 'Boxster', price: 72000 }
];
return (
<div className="ag-theme-alpine" style={{ height: 400, width: 600 }}>
<AgGridReact
columnDefs={columnDefs}
rowData={rowData}
/>
</div>
);
};
export default App;
Row Selection
This code demonstrates how to enable row selection in the grid. It also includes an event handler to log the selected rows to the console.
import React, { useState } from 'react';
import { AgGridReact } from 'ag-grid-react';
import 'ag-grid-community/styles/ag-grid.css';
import 'ag-grid-community/styles/ag-theme-alpine.css';
const App = () => {
const [rowData] = useState([
{ make: 'Toyota', model: 'Celica', price: 35000 },
{ make: 'Ford', model: 'Mondeo', price: 32000 },
{ make: 'Porsche', model: 'Boxster', price: 72000 }
]);
const [columnDefs] = useState([
{ headerName: 'Make', field: 'make' },
{ headerName: 'Model', field: 'model' },
{ headerName: 'Price', field: 'price' }
]);
const onSelectionChanged = (event) => {
const selectedRows = event.api.getSelectedRows();
console.log('Selected rows:', selectedRows);
};
return (
<div className="ag-theme-alpine" style={{ height: 400, width: 600 }}>
<AgGridReact
columnDefs={columnDefs}
rowData={rowData}
rowSelection="single"
onSelectionChanged={onSelectionChanged}
/>
</div>
);
};
export default App;
Custom Cell Renderer
This code demonstrates how to use a custom cell renderer to change the appearance of cell values based on their content. In this example, the price values are colored red if they are greater than 50000 and green otherwise.
import React from 'react';
import { AgGridReact } from 'ag-grid-react';
import 'ag-grid-community/styles/ag-grid.css';
import 'ag-grid-community/styles/ag-theme-alpine.css';
const CustomCellRenderer = (props) => {
return (
<span style={{ color: props.value > 50000 ? 'red' : 'green' }}>
{props.value}
</span>
);
};
const App = () => {
const columnDefs = [
{ headerName: 'Make', field: 'make' },
{ headerName: 'Model', field: 'model' },
{ headerName: 'Price', field: 'price', cellRenderer: 'customCellRenderer' }
];
const rowData = [
{ make: 'Toyota', model: 'Celica', price: 35000 },
{ make: 'Ford', model: 'Mondeo', price: 32000 },
{ make: 'Porsche', model: 'Boxster', price: 72000 }
];
return (
<div className="ag-theme-alpine" style={{ height: 400, width: 600 }}>
<AgGridReact
columnDefs={columnDefs}
rowData={rowData}
frameworkComponents={{ customCellRenderer: CustomCellRenderer }}
/>
</div>
);
};
export default App;
react-table is a lightweight, fast, and extendable data grid built for React. It focuses on providing a simple and flexible API for building tables with features like sorting, filtering, and pagination. Compared to ag-grid-react, react-table is more lightweight and easier to customize but may lack some of the advanced features and performance optimizations of ag-grid-react.
material-table is a data table component built on top of Material-UI. It provides a rich set of features like sorting, filtering, grouping, and editing, along with a modern and responsive design. Compared to ag-grid-react, material-table offers a more integrated experience with Material-UI and is suitable for applications already using Material-UI for their UI components.
react-data-grid is a highly customizable and performant data grid component for React. It offers features like sorting, filtering, grouping, and cell editing. Compared to ag-grid-react, react-data-grid is more focused on performance and customization, making it a good choice for applications that require a high degree of control over the grid's behavior and appearance.
AG Grid is a fully-featured and highly customizable React Data Grid. It delivers outstanding performance and has no third-party dependencies.
AG Grid is available in two versions: Community & Enterprise.
ag-grid-community
is free, available under the MIT license, and comes with all of the core features expected from a React Data Grid, including Sorting, Filtering, Pagination, Editing, Custom Components, Theming and more.ag-grid-enterprise
is available under a commercial license and comes with advanced features, like Integrated Charting, Row Grouping, Aggregation, Pivoting, Master/Detail, Server-side Row Model, and Exporting in addition to dedicated support from our Engineering team.Feature | AG Grid Community | AG Grid Enterprise |
---|---|---|
Filtering | β | β (Advanced) |
Sorting | β | β |
Cell Editing | β | β |
CSV Export | β | β |
Drag & Drop | β | β |
Themes and Styling | β | β |
Selection | β | β |
Accessibility | β | β |
Infinite Scrolling | β | β |
Pagination | β | β |
Server-Side Data | β | β (Advanced) |
Custom Components | β | β |
Integrated Charting | β | β |
Range Selection | β | β |
Row Grouping and Aggregation | β | β |
Pivoting | β | β |
Excel Export | β | β |
Clipboard Operations | β | β |
Master/Detail | β | β |
Tree Data | β | β |
Column Menu | β | β |
Context Menu | β | β |
Tool Panels | β | β |
Support | β | β |
βΉοΈ Note:
Visit the Pricing page for a full comparison.
We've created several demos to showcase AG Grid's rich feature set across different use cases. See them in action below, or interact with them on our Demo page.
Financial data example featuring live updates and sparklines:
AG Grid is easy to set up - all you need to do is provide your data and define your column structure.
$ npm install --save ag-grid-react
1. Import the React Data Grid
// React Data Grid Component
import { AgGridReact } from 'ag-grid-react';
2. Define Rows and Columns
const GridExample = () => {
// Row Data: The data to be displayed.
const [rowData, setRowData] = useState([
{ make: 'Tesla', model: 'Model Y', price: 64950, electric: true },
{ make: 'Ford', model: 'F-Series', price: 33850, electric: false },
{ make: 'Toyota', model: 'Corolla', price: 29600, electric: false },
]);
// Column Definitions: Defines the columns to be displayed.
const [colDefs, setColDefs] = useState([
{ field: 'make' },
{ field: 'model' },
{ field: 'price' },
{ field: 'electric' },
]);
// ...
};
3. React Data Grid Component
return (
// set a height on the parent div because the grid fills the available space
<div style={{ height: 500 }}>
<AgGridReact rowData={rowData} columnDefs={colDefs} />
</div>
);
βΉοΈ Note:
For more information on building Data Grids with AG Grid, refer to our Documentation.
We also provide Seed Projects to help you get started with common configurations:
Environment | Framework | Packages | Modules |
---|---|---|---|
Create React App (CRA) | Packages | Modules | |
Vite | Packages | Modules | |
Vite - TypeScript | Packages | Modules | |
Webpack 5 - TypeScript | Packages | Modules | |
Webpack 5 - React | Packages | Modules | |
Angular CLI | Packages | Modules | |
Nuxt | Packages | Modules | |
Vite | Packages | Modules |
AG Grid is fully customisable, both in terms of appearance and functionality. There are many ways in which the grid can be customised and we provide a selection of tools to help create those customisations.
You can create your own Custom Components to customise the behaviour of the grid. For example, you can customise how cells are rendered, how values are edited and also create your own filters.
There are a number of different Component Types that you can provide to the grid, including:
To supply a custom cell renderer and filter components to the Grid, create a direct reference to your component within the gridOptions.columnDefs
property:
gridOptions = {
columnDefs: [
{
field: 'country', // The column to add the component to
cellRenderer: CountryCellRenderer, // Your custom cell component
filter: CountryFilter, // Your custom filter component
},
],
};
AG Grid has 4 themes, each available in light
& dark
modes:
Quartz | Material |
---|---|
Alpine | Balham |
All AG Grid themes can be customised using the Theming API, or you can create a new theme from scratch with the help of our Theme Builder or Figma Design System.
AG Grid has a large and active community who have created an ecosystem of 3rd party tools, extensions and utilities to help you build your next project with AG Grid, no matter which language or framework you use:
AG Grid is used by 100,000's of developers across the world, from almost every industry. Whilst most of these projects are private, we've curated a selection of open-source projects from different industries where household names use AG Grid, including J.P.Morgan, MongoDB and NASA. Visit our Community Showcase page to learn more.
Founded in 2016, AG Grid has seen a steady rise in popularity and is now the market leader for Data Grids:
AG Grid Enterprise customers have access to dedicated support via ZenDesk, which is monitored by our engineering teams.
If you have found a bug, please report it in this repository's issues section.
Look for similar problems on StackOverflow using the ag-grid
tag. If nothing seems related, post a new message there. Please do not use GitHub issues to ask questions.
AG Grid is developed by a team of co-located developers in London. If you want to join the team send your application to info@ag-grid.com.
ag-grid-community
is licensed under the MIT license.
ag-grid-enterprise
has a Commercial license.
See the LICENSE file for more info.
If you've made it this far, you may be interested in our latest project: AG Charts - The best React Charting library in the world.
Initially built to power Integrated Charts in AG Grid, we open-sourced this project in 2018. Having seen the steady rise in popularity since then, we have decided to invest in AG Charts with a dedicated Enterprise version (ag-charts-enterprise
) in addition to our continued support of ag-charts-community
.
FAQs
AG Grid React Component
The npm package ag-grid-react receives a total of 344,141 weekly downloads. As such, ag-grid-react popularity was classified as popular.
We found that ag-grid-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 4 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.