Skip to content

Instantly share code, notes, and snippets.

@Thanood
Last active March 8, 2016 13:47
Show Gist options
  • Save Thanood/cb24fd70d17d4bb773d1 to your computer and use it in GitHub Desktop.
Save Thanood/cb24fd70d17d4bb773d1 to your computer and use it in GitHub Desktop.
simple ag-grid wrapper
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();
}
}
}
@ajile-in
Copy link

ajile-in commented Mar 8, 2016

Is this approach of grid working with you? do you have any working sample that you can share?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment