@@ -14,14 +14,21 @@ class BootstrapTable extends React.Component {
14
14
super ( props ) ;
15
15
16
16
this . _attachCellEditFunc ( ) ;
17
- let keyField = null ;
17
+ let { keyField} = props ;
18
18
let customSortFuncMap = { } ;
19
19
20
- React . Children . forEach ( this . props . children , function ( column ) {
21
- if ( column . props . isKey ) {
22
- if ( keyField != null ) throw "Error. Multiple key column be detected in TableHeaderColumn." ;
23
- keyField = column . props . dataField ;
24
- }
20
+ if ( ! ( typeof keyField === 'string' && keyField . length ) ) {
21
+ React . Children . forEach ( this . props . children , column => {
22
+ if ( column . props . isKey ) {
23
+ if ( keyField != null ) {
24
+ throw "Error. Multiple key column be detected in TableHeaderColumn." ;
25
+ }
26
+ keyField = column . props . dataField ;
27
+ }
28
+ } , this ) ;
29
+ }
30
+
31
+ React . Children . forEach ( this . props . children , column => {
25
32
if ( column . props . sortFunc ) {
26
33
customSortFuncMap [ column . props . dataField ] = column . props . sortFunc ;
27
34
}
@@ -485,6 +492,7 @@ class BootstrapTable extends React.Component {
485
492
}
486
493
487
494
BootstrapTable . propTypes = {
495
+ keyField : React . PropTypes . string ,
488
496
height : React . PropTypes . string ,
489
497
data : React . PropTypes . array ,
490
498
remote : React . PropTypes . bool , // remote data, default is false
0 commit comments