在 Table 中嵌套 Json - React-Virtualized

Nested Json in Table - React-Virtualized

我正在使用 'react-virtualized' 中的 Table。

我收到了一些嵌套数据,我想在我的自定义行中显示这些数据。 我的问题是将嵌套 json 绑定到我的 Column dataKey。

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

我的专栏

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

谢谢

只需为第 3 列提供 cellDataGetter 值。

如果您只有 1 个字段,它可能是这样的:

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

如果你想显示不止一个,它可能更像:

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