UNPKG

m-grid

Version:

`m-grid@latest` in you project via the terminal.

94 lines (93 loc) 3.32 kB
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'; var MgridComponent = (function () { function MgridComponent() { this.gridOptions = {}; } /** * @return {?} */ MgridComponent.prototype.ngOnInit = function () { this.rowData = this.data.slice(); 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.slice(); } }; /** * @param {?} firstRowData * @return {?} */ MgridComponent.prototype.getColumnDefs = function (firstRowData) { return Object.keys(firstRowData).map(function (key) { return { headerName: key[0].toUpperCase() + key.substring(1), field: key, width: 100, }; }); }; /** * @param {?} params * @return {?} */ MgridComponent.prototype.onGridReady = function (params) { this.griApi = params.api; params.api.sizeColumnsToFit(); params.api.refreshCells(); }; return MgridComponent; }()); MgridComponent.decorators = [ { type: Component, args: [{ selector: 'app-mgrid', template: "\n <ag-grid-angular\n style=\"height: 100%\"\n [class]=\"theme\"\n [gridOptions]=\"gridOptions\"\n [columnDefs]=\"columnDefs\"\n [rowData]=\"data\"\n enableCellChangeFlash\n (gridReady)=\"onGridReady($event)\"\n >\n </ag-grid-angular>", styles: ["\n @import url(C:\\Projects\\m-grid\\node_modules\\ag-grid\\dist\\styles\\ag-grid.css);\n @import url(C:\\Projects\\m-grid\\node_modules\\ag-grid\\dist\\styles\\ag-theme-fresh.css);\n .ag-header .ag-pivot-off .ag-theme-mprest {\n background-color: orange;\n border-color: #FF0000; }\n "], },] }, ]; /** * @nocollapse */ MgridComponent.ctorParameters = function () { return []; }; MgridComponent.propDecorators = { 'theme': [{ type: Input },], 'data': [{ type: Input },], 'options': [{ type: Input },], 'columnDefinitions': [{ type: Input },], }; // Ag-Grid var MgridModule = (function () { function MgridModule() { } return MgridModule; }()); MgridModule.decorators = [ { type: NgModule, args: [{ imports: [ CommonModule, HttpClientModule, AgGridModule.withComponents([]) ], declarations: [MgridComponent], providers: [], exports: [ MgridComponent, AgGridModule ] },] }, ]; /** * @nocollapse */ MgridModule.ctorParameters = function () { return []; }; /** * Generated bundle index. Do not edit. */ export { MgridModule, MgridComponent as ɵa }; //# sourceMappingURL=m-grid.es5.js.map