var gridOptions = {
columnDefs: [
{ field: 'athlete', minWidth: 200 },
{ field: 'age', filter: 'agNumberColumnFilter' },
{ field: 'country', enableRowGroup: true, minWidth: 200 },
{ field: 'year', enableRowGroup: true },
{ field: 'date', minWidth: 180 },
{ field: 'sport', minWidth: 200 },
{ field: 'gold', enableValue: true },
{ field: 'silver', enableValue: true },
{ field: 'bronze', enableValue: true },
{ field: 'total', enableValue: true },
],
defaultColDef: {
flex: 1,
minWidth: 100,
filter: true,
resizable: true,
},
enableRangeSelection: true,
rowSelection: 'multiple',
statusBar: {
statusPanels: [
{ statusPanel: 'agFilteredRowCountComponent' },
{ statusPanel: 'agSelectedRowCountComponent' },
{ statusPanel: 'agAggregationComponent' },
],
},
sideBar: {
toolPanels: [
{
id: 'columns',
labelDefault: 'Columns',
labelKey: 'columns',
iconKey: 'columns',
toolPanel: 'agColumnsToolPanel',
},
{
id: 'filters',
labelDefault: 'Filters',
labelKey: 'filters',
iconKey: 'filter',
toolPanel: 'agFiltersToolPanel',
},
],
},
};
// setup the grid after the page has finished loading
document.addEventListener('DOMContentLoaded', function () {
var gridDiv = document.querySelector('#myGrid');
new agGrid.Grid(gridDiv, gridOptions);
agGrid
.simpleHttpRequest({
url: 'https://www.ag-grid.com/example-assets/olympic-winners.json',
})
.then(function (data) {
gridOptions.api.setRowData(data);
});
});
<!DOCTYPE html>
<html lang="en">
<head>
<title>JavaScript example</title>
<meta charSet="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<style media="only screen">
html, body {
height: 100%;
width: 100%;
margin: 0;
box-sizing: border-box;
-webkit-overflow-scrolling: touch;
}
html {
position: absolute;
top: 0;
left: 0;
padding: 0;
overflow: auto;
}
body {
padding: 1rem;
overflow: auto;
}
</style>
</head>
<body>
<div id="myGrid" style="height: 100%;" class="ag-theme-alpine">
</div>
<script>var __basePath = './';</script>
<script src="https://unpkg.com/@ag-grid-enterprise/all-modules@26.1.0/dist/ag-grid-enterprise.min.js">
</script>
<script src="main.js">
</script>
</body>
</html>