@@ -71,12 +71,22 @@ class TableHeaderColumn extends Component {
71
71
72
72
render ( ) {
73
73
let defaultCaret ;
74
+ const {
75
+ dataAlign,
76
+ headerAlign,
77
+ hidden,
78
+ sort,
79
+ dataSort,
80
+ sortIndicator,
81
+ children,
82
+ caretRender
83
+ } = this . props ;
74
84
const thStyle = {
75
- textAlign : this . props . dataAlign ,
76
- display : this . props . hidden ? 'none' : null
85
+ textAlign : headerAlign || dataAlign ,
86
+ display : hidden ? 'none' : null
77
87
} ;
78
- if ( this . props . sortIndicator ) {
79
- defaultCaret = ( ! this . props . dataSort ) ? null : (
88
+ if ( sortIndicator ) {
89
+ defaultCaret = ( ! dataSort ) ? null : (
80
90
< span className = 'order' >
81
91
< span className = 'dropdown' >
82
92
< span className = 'caret' style = { { margin : '10px 0 10px 5px' , color : '#ccc' } } > </ span >
@@ -87,20 +97,20 @@ class TableHeaderColumn extends Component {
87
97
</ span >
88
98
) ;
89
99
}
90
- let sortCaret = this . props . sort ? Util . renderReactSortCaret ( this . props . sort ) : defaultCaret ;
91
- if ( this . props . caretRender ) {
92
- sortCaret = this . props . caretRender ( this . props . sort ) ;
100
+ let sortCaret = sort ? Util . renderReactSortCaret ( sort ) : defaultCaret ;
101
+ if ( caretRender ) {
102
+ sortCaret = caretRender ( sort ) ;
93
103
}
94
104
95
- const classes = this . props . className + ' ' + ( this . props . dataSort ? 'sort-column' : '' ) ;
96
- const title = typeof this . props . children === 'string' ? { title : this . props . children } : null ;
105
+ const classes = this . props . className + ' ' + ( dataSort ? 'sort-column' : '' ) ;
106
+ const title = typeof children === 'string' ? { title : children } : null ;
97
107
return (
98
108
< th ref = 'header-col'
99
109
className = { classes }
100
110
style = { thStyle }
101
111
onClick = { this . handleColumnClick }
102
112
{ ...title } >
103
- { this . props . children } { sortCaret }
113
+ { children } { sortCaret }
104
114
< div onClick = { e => e . stopPropagation ( ) } >
105
115
{ this . props . filter ? this . getFilters ( ) : null }
106
116
</ div >
@@ -117,6 +127,7 @@ for (const key in Const.FILTER_TYPE) {
117
127
TableHeaderColumn . propTypes = {
118
128
dataField : PropTypes . string ,
119
129
dataAlign : PropTypes . string ,
130
+ headerAlign : PropTypes . string ,
120
131
dataSort : PropTypes . bool ,
121
132
onSort : PropTypes . func ,
122
133
dataFormat : PropTypes . func ,
@@ -155,6 +166,7 @@ TableHeaderColumn.propTypes = {
155
166
156
167
TableHeaderColumn . defaultProps = {
157
168
dataAlign : 'left' ,
169
+ headerAlign : undefined ,
158
170
dataSort : false ,
159
171
dataFormat : undefined ,
160
172
csvFormat : undefined ,
0 commit comments