@@ -31,13 +31,18 @@ class TableBody extends Component {
3131 const noneditableRows = ( cellEdit . nonEditableRows && cellEdit . nonEditableRows ( ) ) || [ ] ;
3232 const unselectable = this . props . selectRow . unselectable || [ ] ;
3333 const isSelectRowDefined = this . _isSelectRowDefined ( ) ;
34- const tableHeader = Utils . renderColGroup ( this . props . columns , this . props . selectRow , 'header' ) ;
34+ const tableHeader = Utils . renderColGroup ( this . props . columns ,
35+ this . props . selectRow , this . props . expandColumnOptions ) ;
3536 const inputType = this . props . selectRow . mode === Const . ROW_SELECT_SINGLE ? 'radio' : 'checkbox' ;
3637 const CustomComponent = this . props . selectRow . customComponent ;
38+ const ExpandColumnCustomComponent = this . props . expandColumnOptions . expandColumnComponent ;
3739 let expandColSpan = this . props . columns . filter ( col => ! col . hidden ) . length ;
3840 if ( isSelectRowDefined && ! this . props . selectRow . hideSelectColumn ) {
3941 expandColSpan += 1 ;
4042 }
43+ if ( this . props . expandColumnOptions . expandColumnVisible ) {
44+ expandColSpan += 1 ;
45+ }
4146
4247 const tableRows = this . props . data . map ( function ( data , r ) {
4348 const tableColumns = this . props . columns . map ( function ( column , i ) {
@@ -118,6 +123,11 @@ class TableBody extends Component {
118123 const selected = this . props . selectedRowKeys . indexOf ( key ) !== - 1 ;
119124 const selectRowColumn = isSelectRowDefined && ! this . props . selectRow . hideSelectColumn ?
120125 this . renderSelectRowColumn ( selected , inputType , disable , CustomComponent , r , data ) : null ;
126+ const expandedRowColumn = this . renderExpandRowColumn (
127+ this . props . expandableRow && this . props . expandableRow ( data ) ,
128+ this . props . expanding . indexOf ( key ) > - 1 ,
129+ ExpandColumnCustomComponent , r , data
130+ ) ;
121131 // add by bluespring for className customize
122132 let trClassName = this . props . trClassName ;
123133 if ( isFun ( this . props . trClassName ) ) {
@@ -134,7 +144,13 @@ class TableBody extends Component {
134144 onSelectRow = { this . handleSelectRow }
135145 onExpandRow = { this . handleClickCell }
136146 unselectableRow = { disable } >
147+ { this . props . expandColumnOptions . expandColumnVisible &&
148+ this . props . expandColumnOptions . expandColumnBeforeSelectColumn &&
149+ expandedRowColumn }
137150 { selectRowColumn }
151+ { this . props . expandColumnOptions . expandColumnVisible &&
152+ ! this . props . expandColumnOptions . expandColumnBeforeSelectColumn &&
153+ expandedRowColumn }
138154 { tableColumns }
139155 </ TableRow > ] ;
140156
@@ -232,6 +248,7 @@ class TableBody extends Component {
232248 } = this . props ;
233249 const selectRowAndExpand = this . _isSelectRowDefined ( ) && ! clickToExpand ? false : true ;
234250 columnIndex = this . _isSelectRowDefined ( ) ? columnIndex - 1 : columnIndex ;
251+ columnIndex = this . _isExpandColumnVisible ( ) ? columnIndex - 1 : columnIndex ;
235252
236253 if ( expandableRow &&
237254 selectRowAndExpand &&
@@ -309,11 +326,34 @@ class TableBody extends Component {
309326 ) ;
310327 }
311328
329+ renderExpandRowColumn ( isExpandableRow , isExpanded , CustomComponent , rowIndex = null ) {
330+ let content = null ;
331+ if ( CustomComponent ) {
332+ content = ( < CustomComponent isExpandableRow = { isExpandableRow } isExpanded = { isExpanded } /> ) ;
333+ } else if ( isExpandableRow ) {
334+ content = ( isExpanded ? '-' : '+' ) ;
335+ } else {
336+ content = ' ' ;
337+ }
338+
339+ return (
340+ < td
341+ className = 'react-bs-table-expand-cell'
342+ onClick = { ( ) => this . handleClickCell ( rowIndex + 1 ) } >
343+ { content }
344+ </ td >
345+ ) ;
346+ }
347+
312348 _isSelectRowDefined ( ) {
313349 return this . props . selectRow . mode === Const . ROW_SELECT_SINGLE ||
314350 this . props . selectRow . mode === Const . ROW_SELECT_MULTI ;
315351 }
316352
353+ _isExpandColumnVisible ( ) {
354+ return this . props . expandColumnOptions . expandColumnVisible ;
355+ }
356+
317357 getHeaderColGrouop = ( ) => {
318358 return this . refs . header . childNodes ;
319359 }
0 commit comments