Set License
Set the license key via the JavaScript method as described below.
ag-Grid checks the license key without making any network calls.
The license key is set once for the grid library. You do not need to set the license key for each instance of
ag-Grid that you create. You must set the license key before you create an instance of ag-Grid.
Note that it is crucial that you pass the key exactly as provided by ag-Grid - do not modify the key in any
way.
If you are distributing your product and including ag-Grid Enterprise, we realise that your license key will be
visible to others. We appreciate that this is happening and just ask that you don't advertise it. Given our
product is JavaScript, there is little we can do to prevent this.
JavaScript
Use this if you are using the bundled version of ag-Grid (e.g. you are using ag-grid-enterprise.js).
agGrid.LicenseManager.setLicenseKey("your license key");
CommonJS
Use this if you are using CommonJS to load ag-Grid.
var enterprise = require("ag-grid-enterprise");
enterprise.LicenseManager.setLicenseKey("your license key");
Do Not Mix Loading Mechanisms
If you mix the methods above (eg if you are using CommonJS in your application, but use the JavaScript approach
above to set license key) then it will not work. This is because the ag-Grid library will be loaded twice,
one will have the license key and the other will be used in your application without the license key.
Angular
We recommend setting the license key in your main boot files (typically named either main.ts or
boot.ts, before you bootstrap your application.
For example:
// other imports...
import {LicenseManager} from "ag-grid-enterprise";
LicenseManager.setLicenseKey("your license key");
// bootstrap your angular application. ie: platformBrowser().bootstrapModuleFactory(..)
React
We recommend setting the license key in your main bootstrap file (typically named index.js), before you bootstrap your application.
For example:
import React from "react";
import {render} from "react-dom";
import "ag-grid-root/dist/styles/ag-grid.css";
import "ag-grid-root/dist/styles/ag-theme-balham.css";
import {LicenseManager} from "ag-grid-enterprise";
LicenseManager.setLicenseKey("your license key");
import App from "./App";
document.addEventListener('DOMContentLoaded', () => {
render(
<App/>,
document.querySelector('#app')
);
});
VueJS
We recommend setting the license key in your main bootstrap file (typically named main.js), before you bootstrap your application.
For example:
import Vue from "vue";
import "../node_modules/ag-grid/dist/styles/ag-grid.css";
import "../node_modules/ag-grid/dist/styles/ag-theme-balham.css";
import "ag-grid-enterprise";
import {LicenseManager} from "ag-grid-enterprise";
LicenseManager.setLicenseKey("your license key");
new Vue({
el: "#el",
...
});
Polymer
You have two choices as to where to set your license key in Polymer.
If you have many components with agGrid in, the we suggest
you run a separate script to reference and set the license key - for example:
<script src="../bower_components/ag-grid-enterprise/dist/ag-grid-enterprise.noStyle.js"></script>
<!-- ag-grid-polymer element -->
<link rel="import" href="../bower_components/ag-grid-polymer/ag-grid-polymer.html">
<!-- your code -->
<!-- licenseKey.js will be responsible for setting the license key across the application -->
<script src="licenseKey.js"></script>
<link rel="import" href="grid-component-one.html">
<link rel="import" href="grid-component-one.html">
// licenseKey.js
agGrid.LicenseManager.setLicenseKey("your license key")
If you have a single component, or a single component that in turn has the child components, you can set the license key in this parent component - for example:
<script src="../bower_components/ag-grid-enterprise/dist/ag-grid-enterprise.noStyle.js"></script>
<!-- ag-grid-polymer element -->
<link rel="import" href="../bower_components/ag-grid-polymer/ag-grid-polymer.html">
<!-- your code -->
<link rel="import" href="main-component-one.html">
<dom-module id="simple-grid-example">
<template id="template">
<div >
<ag-grid-polymer style="width: 100%; height: 350px;"
class="ag-theme-balham"
rowData="{{rowData}}"
columnDefs="{{columnDefs}}"></ag-grid-polymer>
</div>
</template>
<script>
agGrid.LicenseManager.setLicenseKey("your license key")
class SimpleGridExample extends Polymer.Element {
...
}
</script>
Aurelia
For Aurelia users, we suggest you set your License Key in the configure function, as follows:
export function configure(aurelia: Aurelia) {
aurelia.use
.standardConfiguration()
.plugin('ag-grid-aurelia')
.feature('resources');
LicenseManager.setLicenseKey("your license key");
// ...rest of function