1
votes

I'm using Table from 'react-virtualized'.

I receive some nested data that I want to display inside my custom Row. My problem is to bind nested json to my Column dataKey.

    data= 
  {
    name:'Chris',
    age:'15',
    adresse : {
       number:'14',
       street: 'xxx'
               } 
   }

My Column

<Column dataKey="name"    [....] />
<Column dataKey="age" [...] />
<Column dataKey=" ??????" />  // adresse.number ? 

Thanks

1

1 Answers

7
votes

Just supply a cellDataGetter value for the 3rd column.

If you only have the 1 field it could be like:

<Column
  cellDataGetter={({ rowData }) => rowData.address.number}
  dataKey="adresse"
/>

If you want to display more than one it could be more like:

<Column
  cellDataGetter={({ dataKey , rowData }) => rowData.address[dataKey]}
  dataKey="number"
/>
<Column
  cellDataGetter={({ dataKey , rowData }) => rowData.address[dataKey]}
  dataKey="street"
/>