繁体   English   中英

如何在角度 ag 网格中显示数据

[英]How to display data in angular ag grid

https://stackblitz.com/edit/ag-grid-angular-hello-world-pvtbsw?file=src/app/app.component.ts

如何在 ag 网格中显示这些数据?

输出应该是这样的。 在此处输入图片说明

应用程序组件.html

<ag-grid-angular 
    style="width: auto; height: 300px;" 
    class="ag-theme-balham"
    [rowData]="rowData" 
    [columnDefs]="desktopDefaultCols"
    [modules]="modules">

</ag-grid-angular>

app.component.ts

import { Component } from '@angular/core';

import {AllCommunityModules} from "@ag-grid-community/all-modules";

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.scss' ]
})
export class AppComponent  {
   desktopDefaultCols = [
    {
        headerName: "January19", 
         children: [
           {headerName: "PRN 1",
           field: 'prn1'},
           {headerName: "PRN",
           field: 'prn'}
         ]
    },
    {
        headerName: "March19",
        children: [
          {headerName: "Total"}
         ]
    },
    {
        headerName: "May19", 
        children: [
          {headerName: "Total"}
         ]
    },
    {
        headerName: "June19", 
        children: [
          {headerName: "Total"}
         ]
    }

];


    columnDefs = [
        {field: 'make' },
        {field: 'model' },
        {field: 'price'}
    ];

    rowData = [
        { prn1: '10', prn: '0'},
         { prn1: '3', prn: '10'},
          { prn1: '0', prn: '1'},
        { prn1: '0', prn: '0'},
        { prn1: '0', prn: '0'},
    ];

    modules = AllCommunityModules;

}

演示: https : //stackblitz.com/edit/angular-tsy8c1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM