4

I am using Redux to fetch data from my API and this is what my data looks like:

enter image description here

The problem I am facing is a way to display the data from the array of objects named question.

I am using render Cell to render data for rows currently, here is the snippet of that:

return {
      field: item.dbCol, // I've a config file, which reads field name from a loop
      type: item.fieldType,
      width: item.columnWidth,
      renderCell: (params) => {
        return item.elements.map((element, iterator)=>{
          switch (element.columnType) {
             case 'Question':
              return params.row.question.map((item)=><p>{item.answer}</p>);
}

This is what I've tried so far, but I'm not able to get the data from the question object with the right column!

Any help will be really appreciated.

1 Answers1

0

You can try valueGetter and iterate your "Questions". It should work.

I need the same solution. I will prepare this iteration part and update here. Meanwhile you can think if something.

Role List with Permissions as Tags

Similar data as yours

{ field: 'permissions', headerName:'Permissions', type: 'string', width: 200,
            valueGetter:(params)=>{ return params.row.permissions[0].name; }
},
Zeeshan Eqbal
  • 245
  • 2
  • 11