小编Vas*_*ira的帖子

我的农业网格没有显示任何数据

我对 Angular/Typescript 相当陌生。我有点一边学习一边发展。我正在尝试使用从 Json 文件加载的数据构建网格,但在显示数据时遇到一些问题。如果你们能指出我的错误,我会很高兴,因为我的代码编译没有错误,而我现在有点无助。

我将在下面提供我的代码。提前致谢。

my-grid-application.component.ts

@Component({
  selector: 'app-my-grid-application',
  templateUrl: './my-grid-application.component.html'
})
export class MyGridApplicationComponent {
  private gridOptions: GridOptions;
  things:Things[];

  getThings(){
    this.myGridApplicationService.getThings().subscribe( things => 
this.things = things)
  }

constructor( private myGridApplicationService: MyGridApplicationService) {
    this.gridOptions = <GridOptions>{};
    var gridOptions = {
        onGridReady: function() {
    this.gridOptions.api.setRowData(this.things);
        }
    }
    this.gridOptions.columnDefs = [
        {
            headerName: "ID",
            field: "id",
            width: 100
        },
        {
            headerName: "Value",
            field: "value",
            cellRendererFramework: RedComponentComponent,
            width: 100
        },

    ]; 
  } 
}
Run Code Online (Sandbox Code Playgroud)

my-grid-application.service.ts

export class Things{

}

@Injectable()
export class MyGridApplicationService …
Run Code Online (Sandbox Code Playgroud)

javascript json ag-grid angular

5
推荐指数
1
解决办法
5157
查看次数

标签 统计

ag-grid ×1

angular ×1

javascript ×1

json ×1