Skip to content

Commit

Permalink
fix #890
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Dec 17, 2016
1 parent 460ba53 commit 9183e71
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/BootstrapTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class BootstrapTable extends Component {
className: column.props.columnClassName,
columnTitle: column.props.columnTitle,
width: column.props.width,
text: column.props.children,
text: column.props.headerText || column.props.children,
sortFunc: column.props.sortFunc,
sortFuncExtraData: column.props.sortFuncExtraData,
export: column.props.export,
Expand Down Expand Up @@ -843,7 +843,7 @@ class BootstrapTable extends Component {
columns = children.map((column, r) => {
const { props } = column;
return {
name: props.children,
name: props.headerText || props.children,
field: props.dataField,
hiddenOnInsert: props.hiddenOnInsert,
// when you want same auto generate value and not allow edit, example ID field
Expand All @@ -857,7 +857,7 @@ class BootstrapTable extends Component {
});
} else {
columns = [ {
name: children.props.children,
name: children.props.headerText || children.props.children,
field: children.props.dataField,
editable: children.props.editable,
hiddenOnInsert: children.props.hiddenOnInsert
Expand Down
17 changes: 11 additions & 6 deletions src/TableHeaderColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,35 +28,36 @@ class TableHeaderColumn extends Component {
}

getFilters() {
const { headerText, children } = this.props;
switch (this.props.filter.type) {
case Const.FILTER_TYPE.TEXT: {
return (
<TextFilter ref='textFilter' { ...this.props.filter }
columnName={ this.props.children } filterHandler={ this.handleFilter } />
columnName={ headerText || children } filterHandler={ this.handleFilter } />
);
}
case Const.FILTER_TYPE.REGEX: {
return (
<RegexFilter ref='regexFilter' { ...this.props.filter }
columnName={ this.props.children } filterHandler={ this.handleFilter } />
columnName={ headerText || children } filterHandler={ this.handleFilter } />
);
}
case Const.FILTER_TYPE.SELECT: {
return (
<SelectFilter ref='selectFilter' { ...this.props.filter }
columnName={ this.props.children } filterHandler={ this.handleFilter } />
columnName={ headerText || children } filterHandler={ this.handleFilter } />
);
}
case Const.FILTER_TYPE.NUMBER: {
return (
<NumberFilter ref='numberFilter' { ...this.props.filter }
columnName={ this.props.children } filterHandler={ this.handleFilter } />
columnName={ headerText || children } filterHandler={ this.handleFilter } />
);
}
case Const.FILTER_TYPE.DATE: {
return (
<DateFilter ref='dateFilter' { ...this.props.filter }
columnName={ this.props.children } filterHandler={ this.handleFilter } />
columnName={ headerText || children } filterHandler={ this.handleFilter } />
);
}
case Const.FILTER_TYPE.CUSTOM: {
Expand All @@ -75,6 +76,7 @@ class TableHeaderColumn extends Component {
render() {
let defaultCaret;
const {
headerText,
dataAlign,
dataField,
headerAlign,
Expand Down Expand Up @@ -111,7 +113,9 @@ class TableHeaderColumn extends Component {
typeof className === 'function' ? className() : className,
dataSort ? 'sort-column' : '');

const title = headerTitle && typeof children === 'string' ? { title: children } : null;
const title = {
title: ((headerTitle && typeof children === 'string') ? children : headerText)
};
return (
<th ref='header-col'
className={ classes }
Expand Down Expand Up @@ -196,6 +200,7 @@ TableHeaderColumn.propTypes = {
dataAlign: PropTypes.string,
headerAlign: PropTypes.string,
headerTitle: PropTypes.bool,
headerText: PropTypes.string,
dataSort: PropTypes.bool,
onSort: PropTypes.func,
dataFormat: PropTypes.func,
Expand Down

0 comments on commit 9183e71

Please sign in to comment.