我目前正试图在我的angular2项目中注入ag网格,并且我在渲染它时遇到了问题。
我正在尝试使用这个ag-网格包,并按照教程使用命令'dotnet新的角‘生成的.net projet。
这是我的agGrid.component.ts:
import { Component } from '@angular/core';
import { GridOptions } from "ag-grid/main";
@Component({
selector: 'ag-grid-component',
templateUrl: './agGrid.component.html'
})
export class AgGridComponent {
private gridOptions: GridOptions;
public rowData: any[];
private columnDefs: any[];
constructor() {
this.gridOptions = <GridOptions>{};
this.createRowData();
this.createColumnDefs();
this.gridOptions.defaultColDef = {
headerComponentParams: {
menuIcon: 'fa-bars'
}
}
}
private createRowData() {
this.rowData = [
{ make: "Toyota", model: "Celica", price: 35000 },
{ make: "Ford", model: "Mondeo", price: 32000 },
{ make: "Porsche", model: "Boxter", price: 72000 }
];
}
private createColumnDefs() {
this.columnDefs = [
{ headerName: "Make", field: "make" },
{ headerName: "Model", field: "model" },
{ headerName: "Price", field: "price" }
];
}
}
我的agGrid.component.html:
<ag-grid-angular #agGrid style="width:500px;height:200px" class="ag-fresh"
[gridOptions]="gridOptions"
[columnDefs]="columnDefs"
[rowData]="rowData">
</ag-grid-angular>
我仔细地从“ag-格栅-角/主”中导入了AgGridModule,但是结果非常糟糕:
有人能指点我吗?提前谢谢你。
发布于 2017-11-30 08:03:31
新的角2/4和Visual 2017,但也有同样的问题。阅读上面的两个答案非常有帮助。
我做了下面的工作,以便在原来的问题中获得相同的示例
想要一个更优雅的solution...thanks的反馈
发布于 2017-05-15 15:04:36
这是CSS样式加载的一个问题,请确保您已经正确导入了CSS文件。
发布于 2017-06-30 07:10:16
请将下面的行添加到主html文件头中。(以<符号开头)
链接href="/node_modules/ag-grid/dist/styles/ag-grid.css“rel=”样式表“/> link href="/node_modules/ag-grid/dist/styles/theme-fresh.css”rel=“样式表”/>
https://stackoverflow.com/questions/43984072
复制相似问题