Last active
March 8, 2016 13:47
-
-
Save Thanood/cb24fd70d17d4bb773d1 to your computer and use it in GitHub Desktop.
simple ag-grid wrapper
This file contains 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 } from 'aurelia-framework'; | |
import * as ag from 'ag-grid'; | |
@inlineView(` | |
<template class="ag-blue" style="align-self: stretch; flex-grow: 1; -ms-flex: 0 1 auto; flex: 1 1 100%;"> | |
<require from="ag-grid/dist/ag-grid.css"></require> | |
<require from="ag-grid/dist/theme-blue.css"></require> | |
</template> | |
`) | |
export class AgGrid { | |
@bindable columns; | |
@bindable rows; | |
attached() { | |
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); | |
this.gridOptions.api.sizeColumnsToFit() | |
} | |
rowsChanged(newValue, oldValue) { | |
if (newValue && newValue.length) { | |
this.gridOptions.api.setRowData(newValue); | |
this.gridOptions.api.refreshView(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is this approach of grid working with you? do you have any working sample that you can share?