added closeExpanded function to subComponent callback (#1121)

This commit is contained in:
Leonardo Merza
2018-10-04 16:48:18 -04:00
committed by Tanner Linsley
parent 188fc51336
commit 836f256031
2 changed files with 5 additions and 2 deletions

View File

@@ -47,7 +47,7 @@ export default class ComponentTest extends React.component {
// const rtProps = {
// data,
// columns,
// // ExpanderComponent: (props)=><ExpanderComponent {...props} />,
// // ExpanderComponent: (props, closeExpanded)=><ExpanderComponent {...props, closeExpanded} />,
// // SubComponent: (props)=><SubComponent {...props} />,
// // multiSort: false,
// }

View File

@@ -665,7 +665,10 @@ export default class ReactTable extends Methods(Lifecycle(Component)) {
{rowInfo.subRows &&
isExpanded &&
rowInfo.subRows.map((d, i) => makePageRow(d, i, rowInfo.nestingPath))}
{SubComponent && !rowInfo.subRows && isExpanded && SubComponent(rowInfo)}
{SubComponent && !rowInfo.subRows && isExpanded && SubComponent(rowInfo, () => {
let newExpanded = _.clone(expanded)
newExpanded = _.set(newExpanded, cellInfo.nestingPath, false)
})}
</TrGroupComponent>
)
}