@@ -44,11 +44,20 @@ class BootstrapTable extends Component {
4444 this . _adjustHeaderWidth = this . _adjustHeaderWidth . bind ( this ) ;
4545 this . _adjustHeight = this . _adjustHeight . bind ( this ) ;
4646 this . _adjustTable = this . _adjustTable . bind ( this ) ;
47+ this . toggleExpandAllChilds = this . toggleExpandAllChilds . bind ( this ) ;
48+
49+ let expandedKeys = [ ] ;
50+ if ( this . props . options . expandAllChilds !== null &&
51+ this . props . options . expandAllChilds !== undefined && this . props . options . expandAllChilds ) {
52+ expandedKeys = this . store . getAllRowkey ( ) ;
53+ } else if ( this . props . options . expanding !== undefined && this . props . options . expanding !== null ) {
54+ expandedKeys = this . props . options . expanding ;
55+ }
4756
4857 this . state = {
4958 data : this . getTableData ( ) ,
5059 currPage : currPage ,
51- expanding : this . props . options . expanding || [ ] ,
60+ expanding : expandedKeys ,
5261 sizePerPage : this . props . options . sizePerPage || Const . SIZE_PER_PAGE_LIST [ 0 ] ,
5362 selectedRowKeys : this . store . getSelectedRowKeys ( ) ,
5463 reset : false ,
@@ -477,6 +486,10 @@ class BootstrapTable extends Component {
477486 reset = { this . state . reset }
478487 expandColumnVisible = { expandColumnOptions . expandColumnVisible }
479488 expandColumnComponent = { expandColumnOptions . expandColumnComponent }
489+ expandedColumnHeaderComponent = { expandColumnOptions . expandedColumnHeaderComponent }
490+ noAnyExpand = { this . state . expanding . length === 0 }
491+ expandAll = { this . props . options . expandAll }
492+ toggleExpandAllChilds = { this . toggleExpandAllChilds }
480493 expandColumnBeforeSelectColumn = { expandColumnOptions . expandColumnBeforeSelectColumn } >
481494 { this . props . children }
482495 </ TableHeader >
@@ -627,6 +640,25 @@ class BootstrapTable extends Component {
627640 } ) ;
628641 }
629642
643+ toggleExpandAllChilds ( ) {
644+ const { expanding } = this . state ;
645+ if ( expanding . length > 0 ) {
646+ this . setState ( ( ) => {
647+ return {
648+ expanding : [ ] ,
649+ reset : false
650+ } ;
651+ } ) ;
652+ } else {
653+ this . setState ( ( ) => {
654+ return {
655+ expanding : this . store . getAllRowkey ( ) ,
656+ reset : false
657+ } ;
658+ } ) ;
659+ }
660+ }
661+
630662 handlePaginationData = ( page , sizePerPage ) => {
631663 const { onPageChange, pageStartIndex } = this . props . options ;
632664 const emptyTable = this . store . isEmpty ( ) ;
@@ -1704,7 +1736,8 @@ BootstrapTable.propTypes = {
17041736 beforeShowError : PropTypes . func ,
17051737 printToolBar : PropTypes . bool ,
17061738 insertFailIndicator : PropTypes . string ,
1707- noAutoBOM : PropTypes . bool
1739+ noAutoBOM : PropTypes . bool ,
1740+ expandAll : PropTypes . bool
17081741 } ) ,
17091742 fetchInfo : PropTypes . shape ( {
17101743 dataTotalSize : PropTypes . number
@@ -1724,6 +1757,7 @@ BootstrapTable.propTypes = {
17241757 columnWidth : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . string ] ) ,
17251758 expandColumnVisible : PropTypes . bool ,
17261759 expandColumnComponent : PropTypes . func ,
1760+ expandedColumnHeaderComponent : PropTypes . func ,
17271761 expandColumnBeforeSelectColumn : PropTypes . bool
17281762 } ) ,
17291763 footer : PropTypes . bool
@@ -1737,6 +1771,7 @@ BootstrapTable.defaultProps = {
17371771 expandColumnOptions : {
17381772 expandColumnVisible : false ,
17391773 expandColumnComponent : undefined ,
1774+ expandedColumnHeaderComponent : undefined ,
17401775 expandColumnBeforeSelectColumn : true
17411776 } ,
17421777 height : '100%' ,
@@ -1872,7 +1907,8 @@ BootstrapTable.defaultProps = {
18721907 beforeShowError : undefined ,
18731908 printToolBar : true ,
18741909 insertFailIndicator : Const . INSERT_FAIL_INDICATOR ,
1875- noAutoBOM : true
1910+ noAutoBOM : true ,
1911+ expandAll : false
18761912 } ,
18771913 fetchInfo : {
18781914 dataTotalSize : 0
0 commit comments