diff --git a/docs/row-expand.md b/docs/row-expand.md index 8afb1aa..5de4f7b 100644 --- a/docs/row-expand.md +++ b/docs/row-expand.md @@ -92,13 +92,15 @@ const expandRow = { ``` ### expandRow.expandColumnRenderer - [Function] -Provide a callback function which allow you to custom the expand indicator. This callback only have one argument which is an object and contain one property `expanded` which indicate if current row is expanded +Provide a callback function which allow you to custom the expand indicator. This callback only have one argument which is an object and contain two properties: +* `expanded`: Indicate if current row is expanded or not +* `rowKey`: Current row key ```js const expandRow = { renderer: (row) => ... - expandColumnRenderer: ({ expanded }) => ( + expandColumnRenderer: ({ expanded, rowKey }) => ( // .... ) }; diff --git a/packages/react-bootstrap-table2-example/examples/row-expand/custom-expand-column.js b/packages/react-bootstrap-table2-example/examples/row-expand/custom-expand-column.js index 067046d..b1ed8c1 100644 --- a/packages/react-bootstrap-table2-example/examples/row-expand/custom-expand-column.js +++ b/packages/react-bootstrap-table2-example/examples/row-expand/custom-expand-column.js @@ -1,4 +1,5 @@ /* eslint react/prop-types: 0 */ +/* eslint no-unused-vars: 0 */ import React from 'react'; import BootstrapTable from 'react-bootstrap-table-next'; @@ -33,7 +34,7 @@ const expandRow = { } return +; }, - expandColumnRenderer: ({ expanded }) => { + expandColumnRenderer: ({ expanded, rowKey }) => { if (expanded) { return ( - diff --git a/packages/react-bootstrap-table2/src/row-expand/expand-cell.js b/packages/react-bootstrap-table2/src/row-expand/expand-cell.js index 5aa33f5..64b088e 100644 --- a/packages/react-bootstrap-table2/src/row-expand/expand-cell.js +++ b/packages/react-bootstrap-table2/src/row-expand/expand-cell.js @@ -38,7 +38,7 @@ export default class ExpandCell extends Component { } render() { - const { expanded, expandColumnRenderer, tabIndex } = this.props; + const { expanded, expandColumnRenderer, tabIndex, rowKey } = this.props; const attrs = {}; if (tabIndex !== -1) attrs.tabIndex = tabIndex; @@ -46,7 +46,8 @@ export default class ExpandCell extends Component { { expandColumnRenderer ? expandColumnRenderer({ - expanded + expanded, + rowKey }) : (expanded ? '(-)' : '(+)') }