Access Parent Row value from a subcomponent.
Problem Description
I have 2 subcomponents in a react table and when i drill down to second subcomponent from a parents row . I want to access active top parent row values from the present active subcomponent row |-- (parent Row) |-- (1st subcomponent) |-- (2nd subcomponent ,From here I want parent row values)
Steps to Reproduce
|-- (parent Row) |-- (1st subcomponent) |-- (2nd subcomponent ,From here I want parent row values)
Can you post your code? This should be easily possible by referencing the props given to the subComponent
Closing for triage. If you would like to continue investigating this issue, please reopen or join the slack channel for further discussion.
Is there a solution on tis issue, I have the exact same requirement when i try to access row it has data for all the rows that were expanded not able to figure out which row subcomponent currently i am on.
It was never confirmed as an "issue". The SubComponent is passed the rowInfo of the parent row. This is a rich object that contains both the original row as well as the row data that was rendered - along with other metadata about the row as it exists inside ReactTable. The simplest way to verify this is to create a dummy SubComponent (it is a React component) and console.log the props that are passed or simply add this prop to your ReactTable instance: SubComponent={(row) => { console.log("row",row); return null; }}
NOTE: I am not where I can test this or easily check the doco - but that or something similar would provide insight into what is passed in the props.
it may need to be SubComponent={({ row }) => ..... }.
I am using this in multiple places in my code and am rendering a tabbed component with other embedded components and it all works perfectly fine.
In regard to aforementioned "rich object" from @gary-menzel , I just got a problem while combining SubComponent with renderEditable.
<ReactTable
data={data}
columns={
[
{
Header: "Type",
accessor: "type",
Cell: this.renderEditable
}
]
}
SubComponent={row => { ... }}
As we know, the part Cell: this.renderEditable would 'automatically' pass only cellInfo. Would anyone mind telling me how to pass additional parameter on Cell: this.renderEditable while keep passing the cellInfo ?
Thanks.
I have the same problem. My sub component is another react table.
I need to know the row number of the parent, but I get the row number of the inner table.
I am trying to generate a new prop that will deliver the row.index value of the parent But I fail. Any help is appreciated.
<ReactTable
data={this.props.data}
columns = {this.WP2columns}
pageSize={this.props.data.length+1}
showPagination={false}
className="-striped -highlight"
SubComponent={row => {
return (
<div style={{ padding: "0 20px" }}>
{console.log("WP2 SUBTABLE row=", row) }
<ReactTable
data = {row.original.familywp_goal_tasklist}
columns={this.subcolumns}
parentRow = {row.index}
defaultPageSize={3}
showPagination={false}
/>
</div>
)
}}
/>