ag-grid-community is a feature-rich data grid designed for the major JavaScript frameworks. It provides a highly customizable and performant grid component that can handle large datasets and complex data operations.
What are ag-grid-community's main functionalities?
Basic Grid Setup
This code sets up a basic grid with three columns (Make, Model, Price) and three rows of data. It demonstrates how to define column definitions and row data for the grid.
const gridOptions = {
columnDefs: [
{ headerName: 'Make', field: 'make' },
{ headerName: 'Model', field: 'model' },
{ headerName: 'Price', field: 'price' }
],
rowData: [
{ make: 'Toyota', model: 'Celica', price: 35000 },
{ make: 'Ford', model: 'Mondeo', price: 32000 },
{ make: 'Porsche', model: 'Boxster', price: 72000 }
]
};
// Assuming you have a div with id 'myGrid'
new agGrid.Grid(document.getElementById('myGrid'), gridOptions);
Sorting
This code adds sorting functionality to the grid. By setting the 'sortable' property to true in the column definitions, users can sort the data by clicking on the column headers.
This code adds filtering functionality to the grid. By setting the 'filter' property to true in the column definitions, users can filter the data using the filter input boxes that appear in the column headers.
This code adds pagination to the grid. By setting the 'pagination' property to true and defining 'paginationPageSize', the grid will display a limited number of rows per page and provide pagination controls.
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. Compared to ag-grid-community, react-table is more lightweight and easier to customize but may lack some of the advanced features and performance optimizations.
handsontable is a JavaScript/HTML5 data grid component with Excel-like appearance and behavior. It is highly customizable and supports a wide range of features including data validation, sorting, filtering, and more. Compared to ag-grid-community, handsontable offers a more Excel-like experience but may have a steeper learning curve.
slickgrid is a JavaScript grid/spreadsheet component that is highly performant and capable of handling large datasets. It offers a range of features including virtual scrolling, column resizing, and more. Compared to ag-grid-community, slickgrid is known for its performance with large datasets but may require more effort to integrate and customize.
AG Grid is a fully-featured and highly customizable JavaScript Data Grid. It delivers outstanding performance, has no third-party dependencies and comes with support for React, Angular and Vue.
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 Demo
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. Read on for vanilla JavaScript installation instructions, or refer to our framework-specific guides for React, Angular and Vue.
Installation
$ npm install --save ag-grid-community
Setup
1. Provide a Container
Load the AG Grid library and create a blank container div:
<htmllang="en"><head><!-- Includes all JS & CSS for the JavaScript Data Grid --><scriptsrc="https://cdn.jsdelivr.net/npm/ag-grid-community/dist/ag-grid-community.min.js"></script></head><body><!-- Your Data Grid container --><divid="myGrid"></div></body></html>
2. Instantiating the JavaScript Data Grid
Create the Data Grid inside of your container div using createGrid.
// Grid Options: Contains all of the Data Grid configurationsconst gridOptions = {};
// Your Javascript code to create the Data Gridconst myGridElement = document.querySelector('#myGrid');
agGrid.createGrid(myGridElement, gridOptions);
3. Define Rows and Columns
// Grid Options: Contains all of the Data Grid configurationsconst gridOptions = {
// Row Data: The data to be displayed.rowData: [
{ 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.columnDefs: [
{ field: 'make' },
{ field: 'model' },
{ field: 'price' },
{ field: 'electric' },
],
};
4. Styling the JavaScript Data Grid
Add the ag-theme-quartz CSS class to your Data Grid container div to apply the Data Grid's theme.
<!-- Your Data Grid container --><divid="myGrid"class="ag-theme-quartz"style="height: 500px"></div>
βΉοΈ Note:
For more information on building Data Grids with AG Grid, refer to our Documentation.
Seed Projects
We also provide Seed Projects to help you get started with common configurations:
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.
Custom Components
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:
Menu Item Component: To customise the menu items shown in the Column and Context Menus.
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 tocellRenderer: CountryCellRenderer, // Your custom cell componentfilter: CountryFilter, // Your custom filter component
},
],
};
Themes
AG Grid has 4 themes, each available in light & dark modes. We also supply each theme with an auto mode that can toggle the theme based on the users' system preferences:
Quartz
Material
Alpine
Balham
To apply a theme, add the relevant CSS Class to the Data Grid container. For example, to apply the Quartz theme, use the CSS class ag-theme-quartz:
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.
Stargazers
Founded in 2016, AG Grid has seen a steady rise in popularity and is now the market leader for Data Grids:
π€ Support
Enterprise Support
AG Grid Enterprise customers have access to dedicated support via ZenDesk, which is monitored by our engineering teams.
Bug Reports
If you have found a bug, please report it in this repository's issues section.
Questions
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.
Contributing
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.
β οΈ License
ag-grid-community is licensed under the MIT license.
If you've made it this far, you may be interested in our latest project: AG Charts - The best JavaScript 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.
Follow us to keep up to date with all the latest news from AG Grid:
Advanced Data Grid / Data Table supporting Javascript / Typescript / React / Angular / Vue
The npm package ag-grid-community receives a total of 637,351 weekly downloads. As such, ag-grid-community popularity was classified as popular.
We found that ag-grid-community 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.
Package last updated on 30 Oct 2024
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.
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
By Kush Pandya, Philipp Burckhardt, Kirill Boychenko, Orlando BarreraΒ - Β Oct 31, 2024
The npm package for the LottieFiles Player web component was hit with a supply chain attack after a software engineer's npmjs credentials were compromised.