### Install ag-grid-vue3 using NPM
Source: https://ag-grid.com/archive/33.2.3/vue-data-grid/getting-started/index
Installs the `ag-grid-vue3` package, which automatically includes `ag-grid-community`. This is the first step to integrating AG Grid into your Vue project.
```bash
npm install ag-grid-vue3
```
--------------------------------
### Example Vue Data Grid Implementation
Source: https://ag-grid.com/archive/33.2.3/vue-data-grid/getting-started/index
A complete example of a Vue 3 Data Grid application using AG Grid. It includes module registration, component definition, row and column data setup, and default column configurations.
```javascript
import { createApp, defineComponent, ref } from "vue";
import type { ColDef } from "ag-grid-community";
import { AllCommunityModule, ModuleRegistry } from "ag-grid-community";
import { AgGridVue } from "ag-grid-vue3";
ModuleRegistry.registerModules([AllCommunityModule]);
// Row Data Interface
interface IRow {
make: string;
model: string;
price: number;
electric: boolean;
}
// Define the component configuration
const App = defineComponent({
name: "App",
template: `
`,
components: {
AgGridVue,
},
setup() {
const rowData = ref([
{ 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 },
{ make: "Mercedes", model: "EQA", price: 48890, electric: true },
{ make: "Fiat", model: "500", price: 15774, electric: false },
{ make: "Nissan", model: "Juke", price: 20675, electric: false },
]);
const colDefs = ref[]>([
{ field: "make" },
{ field: "model" },
{ field: "price" },
{ field: "electric" },
]);
const defaultColDef = {
flex: 1,
};
return {
rowData,
colDefs,
defaultColDef,
};
},
});
createApp(App).mount("#app");
```
--------------------------------
### Vue Data Grid Component Setup
Source: https://ag-grid.com/archive/33.2.3/vue-data-grid/getting-started/index
Integrates the AG Grid Vue component by binding row data and column definitions as attributes. Styling is applied using standard HTML class and style attributes.
```html
```
--------------------------------
### Import and Register AgGridVue Component in Vue
Source: https://ag-grid.com/archive/33.2.3/vue-data-grid/getting-started/index
Imports the `AgGridVue` component from the `ag-grid-vue3` package and registers it within the Vue application's components. This makes the AG Grid component available for use in your Vue templates.
```javascript
```
--------------------------------
### Register AG Grid Community Modules in Vue
Source: https://ag-grid.com/archive/33.2.3/vue-data-grid/getting-started/index
Registers all available community modules for AG Grid using `ModuleRegistry`. This allows access to all community features within your Vue application. For optimized bundle sizes, consider registering only the modules you intend to use.
```javascript
import { AllCommunityModule, ModuleRegistry } from 'ag-grid-community';
// Register all Community features
ModuleRegistry.registerModules([AllCommunityModule]);
```
--------------------------------
### Define Rows and Columns in Vue
Source: https://ag-grid.com/archive/33.2.3/vue-data-grid/getting-started/index
Defines the row data and column definitions for the AG Grid component using Vue's Composition API. Row data is an array of objects, and column definitions specify which fields to display and how.
```javascript
setup() {
// Row Data: The data to be displayed.
const rowData = ref([
{ 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 = ref([
{ field: "make" },
{ field: "model" },
{ field: "price" },
{ field: "electric" }
]);
return {
rowData,
colDefs,
};
}
```
--------------------------------
### Custom Theme Configuration in JavaScript
Source: https://ag-grid.com/archive/33.2.3/vue-data-grid/getting-started/archive/33.2
Demonstrates how to create a custom theme for AG Grid using the Theming API in JavaScript. This allows for fine-grained control over grid styles, such as spacing, by extending built-in themes like 'Quartz'.
```javascript
import { themeQuartz } from 'ag-grid-community';
const myTheme = themeQuartz.withParams({
"spacing": 8
});
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.