主要是因为AG Grid没有正确地配置列定义或者没有将列与数据绑定。以下是两种常见的
// Column definitions
columnDefs = [
{headerName: 'Make', field: 'make'},
{headerName: 'Model', field: 'model'},
{headerName: 'Price', field: 'price'}
];
// Data
rowData = [
{ make: 'Toyota', model: 'Celica', price: 35000 },
{ make: 'Ford', model: 'Mondeo', price: 32000 },
{ make: 'Porsche', model: 'Boxter', price: 72000 }
];
// Bind the column definitions and data to the grid
// app.module.ts
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { AgGridModule } from "ag-grid-angular";
import { AppComponent } from "./app.component";
@NgModule({
imports: [ BrowserModule, AgGridModule.withComponents([]) ],
declarations: [ AppComponent ],
bootstrap: [ AppComponent ]
})
export class AppModule { }
在你的组件中,你应该正确地定义列和绑定数据到AG Grid。如果你仍然不能显示任何数据,那么请检查浏览器的控制台,看看是否有错误或警告消息。