@@ -44,14 +44,24 @@ class BootstrapTable extends Component {
44
44
this . _adjustHeaderWidth = this . _adjustHeaderWidth . bind ( this ) ;
45
45
this . _adjustHeight = this . _adjustHeight . bind ( this ) ;
46
46
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
+ }
47
56
48
57
this . state = {
49
58
data : this . getTableData ( ) ,
50
59
currPage : currPage ,
51
- expanding : this . props . options . expanding || [ ] ,
60
+ expanding : expandedKeys ,
52
61
sizePerPage : this . props . options . sizePerPage || Const . SIZE_PER_PAGE_LIST [ 0 ] ,
53
62
selectedRowKeys : this . store . getSelectedRowKeys ( ) ,
54
63
reset : false ,
64
+ expandAllChilds : this . props . options . expandAllChilds ,
55
65
x : this . props . keyBoardNav ? 0 : - 1 ,
56
66
y : this . props . keyBoardNav ? 0 : - 1
57
67
} ;
@@ -477,6 +487,10 @@ class BootstrapTable extends Component {
477
487
reset = { this . state . reset }
478
488
expandColumnVisible = { expandColumnOptions . expandColumnVisible }
479
489
expandColumnComponent = { expandColumnOptions . expandColumnComponent }
490
+ expandedColumnHeaderComponent = { expandColumnOptions . expandedColumnHeaderComponent }
491
+ expandAllChilds = { this . state . expandAllChilds }
492
+ toggleExpandAllChilds = { this . toggleExpandAllChilds }
493
+ showExpandAllHeaderColumn = { this . props . options . showExpandAllHeaderColumn }
480
494
expandColumnBeforeSelectColumn = { expandColumnOptions . expandColumnBeforeSelectColumn } >
481
495
{ this . props . children }
482
496
</ TableHeader >
@@ -627,6 +641,28 @@ class BootstrapTable extends Component {
627
641
} ) ;
628
642
}
629
643
644
+ toggleExpandAllChilds ( ) {
645
+ const { expandAllChilds } = this . state ;
646
+ const compScope = this ;
647
+ if ( expandAllChilds ) {
648
+ this . setState ( ( ) => {
649
+ return {
650
+ expanding : [ ] ,
651
+ expandAllChilds : ! expandAllChilds ,
652
+ reset : false
653
+ } ;
654
+ } ) ;
655
+ } else {
656
+ this . setState ( ( ) => {
657
+ return {
658
+ expanding : compScope . store . getAllRowkey ( ) ,
659
+ expandAllChilds : ! expandAllChilds ,
660
+ reset : false
661
+ } ;
662
+ } ) ;
663
+ }
664
+ }
665
+
630
666
handlePaginationData = ( page , sizePerPage ) => {
631
667
const { onPageChange, pageStartIndex } = this . props . options ;
632
668
const emptyTable = this . store . isEmpty ( ) ;
@@ -1704,7 +1740,9 @@ BootstrapTable.propTypes = {
1704
1740
beforeShowError : PropTypes . func ,
1705
1741
printToolBar : PropTypes . bool ,
1706
1742
insertFailIndicator : PropTypes . string ,
1707
- noAutoBOM : PropTypes . bool
1743
+ noAutoBOM : PropTypes . bool ,
1744
+ expandAllChilds : PropTypes . bool ,
1745
+ showExpandAllHeaderColumn : PropTypes . bool
1708
1746
} ) ,
1709
1747
fetchInfo : PropTypes . shape ( {
1710
1748
dataTotalSize : PropTypes . number
@@ -1724,6 +1762,7 @@ BootstrapTable.propTypes = {
1724
1762
columnWidth : PropTypes . oneOfType ( [ PropTypes . number , PropTypes . string ] ) ,
1725
1763
expandColumnVisible : PropTypes . bool ,
1726
1764
expandColumnComponent : PropTypes . func ,
1765
+ expandedColumnHeaderComponent : PropTypes . func ,
1727
1766
expandColumnBeforeSelectColumn : PropTypes . bool
1728
1767
} ) ,
1729
1768
footer : PropTypes . bool
@@ -1737,6 +1776,7 @@ BootstrapTable.defaultProps = {
1737
1776
expandColumnOptions : {
1738
1777
expandColumnVisible : false ,
1739
1778
expandColumnComponent : undefined ,
1779
+ expandedColumnHeaderComponent : undefined ,
1740
1780
expandColumnBeforeSelectColumn : true
1741
1781
} ,
1742
1782
height : '100%' ,
@@ -1872,7 +1912,9 @@ BootstrapTable.defaultProps = {
1872
1912
beforeShowError : undefined ,
1873
1913
printToolBar : true ,
1874
1914
insertFailIndicator : Const . INSERT_FAIL_INDICATOR ,
1875
- noAutoBOM : true
1915
+ noAutoBOM : true ,
1916
+ expandAllChilds : false ,
1917
+ showExpandAllHeaderColumn : false
1876
1918
} ,
1877
1919
fetchInfo : {
1878
1920
dataTotalSize : 0
0 commit comments