mirror of
https://github.com/gosticks/react-bootstrap-table2.git
synced 2026-06-28 21:20:04 +00:00
Merge branch 'develop' into fix-nonExpandable-indicator-and-behaviour
This commit is contained in:
@@ -92,13 +92,15 @@ const expandRow = {
|
||||
```
|
||||
|
||||
### <a name='expandColumnRenderer'>expandRow.expandColumnRenderer - [Function]</a>
|
||||
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 }) => (
|
||||
// ....
|
||||
)
|
||||
};
|
||||
|
||||
@@ -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 <b>+</b>;
|
||||
},
|
||||
expandColumnRenderer: ({ expanded }) => {
|
||||
expandColumnRenderer: ({ expanded, rowKey }) => {
|
||||
if (expanded) {
|
||||
return (
|
||||
<b>-</b>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-bootstrap-table2-example",
|
||||
"version": "1.0.10",
|
||||
"version": "1.0.11",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"private": true,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-bootstrap-table-next",
|
||||
"version": "1.4.1",
|
||||
"version": "1.4.2",
|
||||
"description": "Next generation of react-bootstrap-table",
|
||||
"main": "./lib/index.js",
|
||||
"repository": {
|
||||
|
||||
@@ -39,7 +39,7 @@ export default class ExpandCell extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { expanded, nonExpandable, expandColumnRenderer, tabIndex } = this.props;
|
||||
const { expanded, nonExpandable, expandColumnRenderer, tabIndex, rowKey } = this.props;
|
||||
const attrs = {};
|
||||
const isExpandable = !nonExpandable || !nonExpandable.includes(this.props.rowKey);
|
||||
if (tabIndex !== -1) attrs.tabIndex = tabIndex;
|
||||
@@ -48,7 +48,8 @@ export default class ExpandCell extends Component {
|
||||
<td onClick={ this.handleClick } { ...attrs }>
|
||||
{
|
||||
expandColumnRenderer ? expandColumnRenderer({
|
||||
expanded
|
||||
expanded,
|
||||
rowKey
|
||||
}) : (isExpandable ? (expanded ? '(-)' : '(+)') : '')
|
||||
}
|
||||
</td>
|
||||
|
||||
Reference in New Issue
Block a user