简体   繁体   English

React antd 表已扩展行渲染

[英]React antd table expandedRowRender

I'm in need of some help.我需要一些帮助。

I have a datasource on my antd table in my React.Component.我的 React.Component 中的 antd 表上有一个数据源。 On that table i've set the attribute expandedRowRender:在该表上,我设置了属性 expandRowRender:

  <Table
    bordered
    size="small"
    columns={columns}
    rowKey={record => record.id}
    expandedRowRender={record => (
      <ProductDetailView
        record={record}
        onChange={this.OnCoverageProductNumberChanged()}
      />
    )}
    dataSource={products}
    pagination={this.state.pagination}
    loading={this.props.isProductsLoading}
    onChange={this.handleChange}
  />

which is currently sending a record to ProductDetailView which is a react.component.当前正在向 ProductDetailView 发送一条记录,这是一个 react.component。 I would like to know how I can send the row index to the onChange event as well, so I can track on which row I am looking at.我也想知道如何将行索引发送到 onChange 事件,以便我可以跟踪我正在查看的行。

I hope this is enough information, basically I just need to know how to send the row index to my onChange event.我希望这是足够的信息,基本上我只需要知道如何将行索引发送到我的 onChange 事件。

Thank you in advance.先感谢您。

The second variable of第二个变量

expandedRowRender={(record, i) => <p>{i}</p>}

is the row index是行索引

you can pass it like this你可以这样通过

expandedRowRender={(record, i) => 
    <ProductDetailView 
        record={record} 
        onChange={() => this.OnCoverageProductNumberChanged(i)}
    />
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM