m-grid
Version:
`m-grid@latest` in you project via the terminal.
110 lines (105 loc) • 2.99 kB
JavaScript
import { Component, Input, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { HttpClientModule } from '@angular/common/http';
import { AgGridModule } from 'ag-grid-angular/main';
class MgridComponent {
constructor() {
this.gridOptions = {};
}
/**
* @return {?}
*/
ngOnInit() {
this.rowData = [...this.data];
this.gridOptions = Object.assign({ rowSelection: true }, this.options);
// Check if column defs are provided
if (this.columnDefinitions === undefined) {
this.columnDefs = this.getColumnDefs(this.data[0]);
}
else {
this.columnDefs = [...this.columnDefinitions];
}
}
/**
* @param {?} firstRowData
* @return {?}
*/
getColumnDefs(firstRowData) {
return Object.keys(firstRowData).map((key) => {
return {
headerName: key[0].toUpperCase() + key.substring(1),
field: key,
width: 100,
};
});
}
/**
* @param {?} params
* @return {?}
*/
onGridReady(params) {
this.griApi = params.api;
params.api.sizeColumnsToFit();
params.api.refreshCells();
}
}
MgridComponent.decorators = [
{ type: Component, args: [{
selector: 'app-mgrid',
template: `
<ag-grid-angular
style="height: 100%"
[class]="theme"
[gridOptions]="gridOptions"
[columnDefs]="columnDefs"
[rowData]="data"
enableCellChangeFlash
(gridReady)="onGridReady($event)"
>
</ag-grid-angular>`,
styles: [`
url(C:\\Projects\\m-grid\\node_modules\\ag-grid\\dist\\styles\\ag-grid.css);
url(C:\\Projects\\m-grid\\node_modules\\ag-grid\\dist\\styles\\ag-theme-fresh.css);
.ag-header .ag-pivot-off .ag-theme-mprest {
background-color: orange;
border-color: #FF0000; }
`],
},] },
];
/**
* @nocollapse
*/
MgridComponent.ctorParameters = () => [];
MgridComponent.propDecorators = {
'theme': [{ type: Input },],
'data': [{ type: Input },],
'options': [{ type: Input },],
'columnDefinitions': [{ type: Input },],
};
// Ag-Grid
class MgridModule {
}
MgridModule.decorators = [
{ type: NgModule, args: [{
imports: [
CommonModule,
HttpClientModule,
AgGridModule.withComponents([])
],
declarations: [MgridComponent],
providers: [],
exports: [
MgridComponent,
AgGridModule
]
},] },
];
/**
* @nocollapse
*/
MgridModule.ctorParameters = () => [];
/**
* Generated bundle index. Do not edit.
*/
export { MgridModule, MgridComponent as ɵa };
//# sourceMappingURL=m-grid.js.map