From e8930f63a76fb54bcb4b36e39440ab757619490f Mon Sep 17 00:00:00 2001 From: AllenFang Date: Thu, 9 Jun 2016 14:51:41 +0800 Subject: [PATCH] fix #494 --- src/TableHeaderColumn.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/TableHeaderColumn.js b/src/TableHeaderColumn.js index b78bff8b2..c411c0446 100644 --- a/src/TableHeaderColumn.js +++ b/src/TableHeaderColumn.js @@ -71,12 +71,22 @@ class TableHeaderColumn extends Component { render() { let defaultCaret; + const { + dataAlign, + headerAlign, + hidden, + sort, + dataSort, + sortIndicator, + children, + caretRender + } = this.props; const thStyle = { - textAlign: this.props.dataAlign, - display: this.props.hidden ? 'none' : null + textAlign: headerAlign || dataAlign, + display: hidden ? 'none' : null }; - if (this.props.sortIndicator) { - defaultCaret = (!this.props.dataSort) ? null : ( + if (sortIndicator) { + defaultCaret = (!dataSort) ? null : ( @@ -87,20 +97,20 @@ class TableHeaderColumn extends Component { ); } - let sortCaret = this.props.sort ? Util.renderReactSortCaret(this.props.sort) : defaultCaret; - if (this.props.caretRender) { - sortCaret = this.props.caretRender(this.props.sort); + let sortCaret = sort ? Util.renderReactSortCaret(sort) : defaultCaret; + if (caretRender) { + sortCaret = caretRender(sort); } - const classes = this.props.className + ' ' + (this.props.dataSort ? 'sort-column' : ''); - const title = typeof this.props.children === 'string' ? { title: this.props.children } : null; + const classes = this.props.className + ' ' + (dataSort ? 'sort-column' : ''); + const title = typeof children === 'string' ? { title: children } : null; return ( - { this.props.children }{ sortCaret } + { children }{ sortCaret }
e.stopPropagation() }> { this.props.filter ? this.getFilters() : null }
@@ -117,6 +127,7 @@ for (const key in Const.FILTER_TYPE) { TableHeaderColumn.propTypes = { dataField: PropTypes.string, dataAlign: PropTypes.string, + headerAlign: PropTypes.string, dataSort: PropTypes.bool, onSort: PropTypes.func, dataFormat: PropTypes.func, @@ -155,6 +166,7 @@ TableHeaderColumn.propTypes = { TableHeaderColumn.defaultProps = { dataAlign: 'left', + headerAlign: undefined, dataSort: false, dataFormat: undefined, csvFormat: undefined,