Last active
April 7, 2016 13:03
-
-
Save Thanood/f6dc31074cb697f6d231 to your computer and use it in GitHub Desktop.
Aurelia - ag-grid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { bindable, inlineView, inject } from 'aurelia-framework'; | |
// import * as ag from 'ag-grid'; | |
@inject(Element) | |
@inlineView(` | |
<template class="ag-blue" style="align-self: stretch; flex-grow: 1; -ms-flex: 0 1 auto; flex: 1 1 100%;"> | |
</template> | |
`) | |
export class AgGrid { | |
@bindable columns; | |
@bindable rows; | |
constructor(element) { | |
this.element = element; | |
} | |
bind() { | |
let cols = this.columns.map(function(col) { | |
return { | |
headerName: col.title, | |
field: col.field, | |
cellRenderer: col.render | |
}; | |
}); | |
let gridOptions = { | |
columnDefs: cols, | |
rowData: this.rows | |
}; | |
this.gridOptions = gridOptions; | |
//ag.angularGrid('ag-grid', gridOptions); | |
new agGrid.Grid(this.element, gridOptions); | |
this.gridOptions.api.sizeColumnsToFit() | |
} | |
rowsChanged(newValue, oldValue) { | |
if (newValue && newValue.length) { | |
this.gridOptions.api.setRowData(newValue); | |
this.gridOptions.api.refreshView(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<require from="./ag-grid"></require> | |
test | |
<ag-grid columns.bind="columns" rows.bind="rows"></ag-grid> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class App { | |
constructor() { | |
this.columns = [ | |
{ title: 'Title', field: 'title' }, | |
{ title: 'another', field: 'another' } | |
]; | |
this.rows = [ | |
{ title: 'item', another: 1 }, | |
{ title: 'item', another: 2 }, | |
{ title: 'item', another: 3 }, | |
{ title: 'item', another: 4 }, | |
{ title: 'item', another: 5 }, | |
{ title: 'item', another: 6 }, | |
{ title: 'item', another: 7 }, | |
{ title: 'item', another: 8 }, | |
{ title: 'item', another: 9 } | |
]; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<link rel="stylesheet" href="https://www.ag-grid.com/dist/ag-grid.css"> | |
<link rel="stylesheet" href="https://www.ag-grid.com/dist/theme-blue.css"> | |
<link rel="stylesheet" href="styles.css"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body aurelia-app="main"> | |
<h1>Loading...</h1> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-plunker/v0.11.10/jspm_packages/system.js"></script> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-plunker/v0.11.10/config2.js"></script> | |
<script src="https://www.ag-grid.com/dist/ag-grid.js"></script> | |
<script> | |
System.import('aurelia-bootstrapper'); | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************************************* | |
* The following two lines enable async/await without using babel's | |
* "runtime" transformer. Uncomment the lines if you intend to use async/await. | |
* | |
* More info here: https://github.com/jdanyow/aurelia-plunker/issues/2 | |
*/ | |
//import regeneratorRuntime from 'babel-runtime/regenerator'; | |
//window.regeneratorRuntime = regeneratorRuntime; | |
/******************************************************************************/ | |
export function configure(aurelia) { | |
aurelia.use | |
.standardConfiguration() | |
.developmentLogging(); | |
//agGrid.initialiseAgGridWithWebComponents(); | |
aurelia.start().then(a => a.setRoot()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Styles go here */ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment