最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - React antd table expandedRowRender - Stack Overflow

programmeradmin1浏览0评论

I'm in need of some help.

I have a datasource on my antd table in my React.Component. On that table i've set the attribute expandedRowRender:

  <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 reactponent. 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.

I hope this is enough information, basically I just need to know how to send the row index to my onChange event.

Thank you in advance.

I'm in need of some help.

I have a datasource on my antd table in my React.Component. On that table i've set the attribute expandedRowRender:

  <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.ponent. 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.

I hope this is enough information, basically I just need to know how to send the row index to my onChange event.

Thank you in advance.

Share Improve this question edited Oct 16, 2017 at 8:19 palaѕн 74k17 gold badges122 silver badges139 bronze badges asked Oct 16, 2017 at 8:16 Max MazurMax Mazur 1,3162 gold badges14 silver badges24 bronze badges 2
  • You want to send row index to the onChange for ProductDetailView ponent or for Table ponent? – Nandu Kalidindi Commented Oct 16, 2017 at 8:24
  • the tables row index which productdetailview is created on. That would be nice. – Max Mazur Commented Oct 16, 2017 at 8:26
Add a ment  | 

1 Answer 1

Reset to default 6

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)}
    />
}
发布评论

评论列表(0)

  1. 暂无评论