Угол 6: как визуализировать ag-grid rowData с массивом? - PullRequest
0 голосов
/ 26 января 2019
{
  "People": [
    {
      "name": "Andrew Amernante",
      "rating": 3,

      "Description": "Gluten-free cray cardigan vegan. Lumbersexual pork belly blog, fanny pack put a bird on it selvage",
      "Likes": [
        "Dogs",
        "Long walks on the beach",
        "Chopin",
        "Tacos"
      ],
      "Dislikes": [
        "Birds",
        "Red things",
        "Danish food",
        "Dead Batteries"
      ]
    },
    {
      "name": "Frank Wang",
      "rating": 5,
      "img": "http://www.fillmurray.com/200/200",
      "Description": "Before errors, mails were only pressures. This is not to discredit the idea that a magic is the prose of an elizabeth. This could be, or perhaps some posit the outmost coil to be less than dedal. Some assert that those treatments are nothing more than carp.",
      "Likes": [
        "Frank",
        "Manchester United",
        "Football",
        "Programming"
      ],
      "Dislikes": [
        "Dogs",
        "Long walks on the beach",
        "Chopin",
        "Tacos"
      ]
    },
    {
      "name": "Sissi Chen",
      "rating": 5,

      "Description": "Aaah! Natural light! Get it off me! Get it off me! Oh, loneliness and cheeseburgers are a dangerous mix. D'oh. Here's to alcohol, the cause of — and solution to — all life's problems.",
      "Likes": [
        "Cats",
        "the beach",
        "Chopin",
        "Blue things"
      ],
      "Dislikes": [
        "Birds"
      ]
    },
    {
      "name": "Diego Garcia",
      "rating": 2,

      "Description": "Facts are meaningless. You could use facts to prove anything that's even remotely true! I prefer a vehicle that doesn't hurt Mother Earth. It's a go-cart, powered by my own sense of self-satisfaction. You don't win friends with salad.",
      "Likes": [
        "Talking Spanish",
        "Spanish food",
        "Spanish things",
        "Football"
      ],
      "Dislikes": [
        "Not talking spanish",
        "Chopin"
      ]
    },
    {
      "name": "Fuad Rashid",
      "rating": 4,

      "Description": "Gluten-free cray cardigan vegan. Lumbersexual pork belly blog, fanny pack put a bird on it selvage",
      "Likes": [
        "Dogs",
        "Long walks on the beach",
        "Chopin",
        "Tacos"
      ],
      "Dislikes": [
        "Birds",
        "Red things",
        "Danish food",
        "Dead Batteries"
      ]
    }
  ]
}

Мне нужно создать таблицу ag-grid из приведенных выше данных JSON с лайками и без в качестве заголовков.Я пытался, но не могу получить лайков и не как rowData в моей таблице.

Я использую этот код:

this.likes.forEach(e=>{
    this.list[index] = {
        'Likes' : e,

    };
    index++
})
this.dislikes.forEach(e=>{
    this.list[index] = {
        'Dislikes' : e

    };
    index++;
});
this.rowData=this.list;
console.log(this.list);
this.rowData=this.list;

Однако я получаю следующую ошибку:

ОШИБКА TypeError: rowData.forEach не является функцией

Таблица должна выглядеть следующим образом:

Table

...