1

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 Answer 1

7

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"
/>
Sign up to request clarification or add additional context in comments.

1 Comment

I ddin't see cellDataGetter props ! Very usefull. Thanks as always brian !

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.