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 forTable
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
1 Answer
Reset to default 6The 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)}
/>
}