@@ -31,19 +31,15 @@ class TableHeader extends Component {
31
31
'table-bordered' : this . props . bordered ,
32
32
'table-condensed' : this . props . condensed
33
33
} , this . props . tableHeaderClass ) ;
34
- let i = 0 ;
35
34
36
- let rowCount = 0 ;
37
- React . Children . forEach ( this . props . children , ( elm ) => {
38
- if ( Number ( elm . props . row ) > rowCount ) {
39
- rowCount = Number ( elm . props . row ) ;
40
- }
41
- } ) ;
35
+ const rowCount = Math . max ( React . Children . map ( this . props . children , elm =>
36
+ Number ( elm . props . row ) ) ) ;
42
37
43
38
const rows = [ ] ;
39
+ let rowKey = 0 ;
44
40
45
41
if ( ! this . props . hideSelectColumn ) {
46
- rows [ 0 ] = [ this . renderSelectRowHeader ( rowCount + 1 ) ] ;
42
+ rows [ 0 ] = [ this . renderSelectRowHeader ( rowCount + 1 , rowKey ++ ) ] ;
47
43
}
48
44
49
45
React . Children . forEach ( this . props . children , ( elm ) => {
@@ -57,11 +53,11 @@ class TableHeader extends Component {
57
53
}
58
54
if ( ( rowSpan + rowIndex ) === ( rowCount + 1 ) ) {
59
55
rows [ rowIndex ] . push ( React . cloneElement (
60
- elm , { key : i ++ , onSort, sort, sortIndicator, isOnlyHead : false }
56
+ elm , { key : rowKey ++ , onSort, sort, sortIndicator, isOnlyHead : false }
61
57
) ) ;
62
58
} else {
63
59
rows [ rowIndex ] . push ( React . cloneElement (
64
- elm , { key : i ++ , isOnlyHead : true }
60
+ elm , { key : rowKey ++ , isOnlyHead : true }
65
61
) ) ;
66
62
}
67
63
} ) ;
@@ -90,21 +86,21 @@ class TableHeader extends Component {
90
86
return this . refs . headerGrp . childNodes ;
91
87
}
92
88
93
- renderSelectRowHeader ( rowCount ) {
89
+ renderSelectRowHeader ( rowCount , rowKey ) {
94
90
if ( this . props . customComponent ) {
95
91
const CustomComponent = this . props . customComponent ;
96
92
return (
97
- < SelectRowHeaderColumn rowCount = { rowCount } >
93
+ < SelectRowHeaderColumn key = { rowKey } rowCount = { rowCount } >
98
94
< CustomComponent type = 'checkbox' checked = { this . props . isSelectAll }
99
95
indeterminate = { this . props . isSelectAll === 'indeterminate' } disabled = { false }
100
96
onChange = { this . props . onSelectAllRow } rowIndex = 'Header' />
101
97
</ SelectRowHeaderColumn >
102
98
) ;
103
99
} else if ( this . props . rowSelectType === Const . ROW_SELECT_SINGLE ) {
104
- return ( < SelectRowHeaderColumn rowCount = { rowCount } /> ) ;
100
+ return ( < SelectRowHeaderColumn key = { rowKey } rowCount = { rowCount } /> ) ;
105
101
} else if ( this . props . rowSelectType === Const . ROW_SELECT_MULTI ) {
106
102
return (
107
- < SelectRowHeaderColumn rowCount = { rowCount } >
103
+ < SelectRowHeaderColumn key = { rowKey } rowCount = { rowCount } >
108
104
< Checkbox
109
105
onChange = { this . props . onSelectAllRow }
110
106
checked = { this . props . isSelectAll } />
0 commit comments