如何在ngx-datatable中显示多维数据

时间:2018-11-02 10:20:29

标签: angular angular6 ngx-datatable

我正在使用Angular 6ngx-datatable

我有类似多维格式的数据

[
  {
    "remote": {
      "app_name": "Test 1",
      "app_url": "https://app.example1.io",
      "created": "2018-10-31T09:01:32+00:00"
    },
    "users": [
      {
        "name": "Example 1",
        "email": "example1@gmail.com",
        "ip_address": null,
        "created": "2018-10-30 19:26:57"
      },
      {
        "name": "Example 2",
        "email": "example2@ymail.com",
        "ip_address": null,
        "created": "2018-10-30 16:05:17"
      }
    ]
  },

  {
    "remote": {
      "app_name": "Test 2",
      "app_url": "https://app.example2.io",
      "created": "2018-10-31T09:01:32+00:00"
    },
    "users": [
      {
        "name": "Example 3",
        "email": "example3@gmail.com",
        "ip_address": null,
        "created": "2018-10-30 19:26:57"
      },
      {
        "name": "Example 4",
        "email": "example4@ymail.com",
        "ip_address": null,
        "created": "2018-10-30 16:05:17"
      }
    ]
  }
]

此处根数组元素具有两个键remoteusers,其中users也是一个数组。

我想以以下格式显示数据

enter image description here

如果子属性是单个属性,则可以使用(。)分隔符,例如

columns = [
  {
    prop: 'remote.app_name',
    name: 'Application Name',
    sortable: true
  }
];

但是如何在数据表列中为用户名和电子邮件定义prop

0 个答案:

没有答案