Last active
April 28, 2016 06:36
-
-
Save Thanood/dd8307fdce4ae6e5f5acc2c38d667c06 to your computer and use it in GitHub Desktop.
Aurelia - ag-grid element
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> | |
<ag-grid ref="myGrid" rowclicked.trigger="onRowClicked($event)" class="ag-blue"></ag-grid> | |
<div show.bind="selected"> | |
selected row: ${selected.make} ${selected.model} | |
</div> | |
<div> | |
<button click.delegate="addData()">add a row</button> | |
</div> | |
</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
import {bindable} from 'aurelia-framework'; | |
export class App { | |
columnDefs = [ | |
{headerName: "Make", field: "make"}, | |
{headerName: "Model", field: "model"}, | |
{headerName: "Price", field: "price"} | |
]; | |
@bindable() rowData = [ | |
{make: "Toyota", model: "Celica", price: 35000}, | |
{make: "Ford", model: "Mondeo", price: 32000}, | |
{make: "Porsche", model: "Boxter", price: 72000} | |
]; | |
selected = null; | |
constructor() { | |
this.gridOptions = { | |
columnDefs: this.columnDefs, | |
rowData: this.rowData | |
}; | |
} | |
attached() { | |
this.myGrid.setGridOptions(this.gridOptions); | |
} | |
rowDataChanged(newValue) { | |
if (newValue && newValue.length) { | |
this.gridOptions.api.setRowData(newValue); | |
this.gridOptions.api.refreshView(); | |
} | |
} | |
addData() { | |
let data = { make: "Daimler", model: "E 200", price: 51000 }; | |
this.rowData.push(data) | |
// somehow the bindable is not updated | |
this.rowDataChanged(this.rowData); | |
} | |
onRowClicked(e) { | |
//console.log(e); | |
this.selected = e.agGridDetails.node.data; | |
} | |
} |
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