Skip to content

Commit

Permalink
fix #1562
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenFang committed Aug 21, 2017
1 parent b1384cd commit cd93a3f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/TableBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class TableBody extends Component {
);
} else {
// add by bluespring for className customize
let formattedValue;
let columnChild = fieldValue && fieldValue.toString();
let columnTitle = null;
let tdClassName = column.className;
Expand All @@ -99,17 +100,22 @@ class TableBody extends Component {
}

if (typeof column.format !== 'undefined') {
const formattedValue = column.format(fieldValue, data, column.formatExtraData, r);
formattedValue = column.format(fieldValue, data, column.formatExtraData, r);
if (!React.isValidElement(formattedValue)) {
columnChild = (
<div dangerouslySetInnerHTML={ { __html: formattedValue } }></div>
);
} else {
columnChild = formattedValue;
columnTitle = column.columnTitle && formattedValue ? formattedValue.toString() : null;
}
} else {
columnTitle = column.columnTitle && fieldValue ? fieldValue.toString() : null;
}
if (Utils.isFunction(column.columnTitle)) {
columnTitle = column.columnTitle(fieldValue, data);
} else if (typeof column.columnTitle === 'string') {
columnTitle = column.columnTitle;
} else if (column.columnTitle) {
if (formattedValue) columnTitle = formattedValue.toString();
else if (fieldValue) columnTitle = fieldValue.toString();
}
return (
<TableColumn key={ i }
Expand Down
6 changes: 5 additions & 1 deletion src/TableHeaderColumn.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ TableHeaderColumn.propTypes = {
columnClassName: PropTypes.any,
editColumnClassName: PropTypes.any,
invalidEditColumnClassName: PropTypes.any,
columnTitle: PropTypes.bool,
columnTitle: PropTypes.oneOfType([
PropTypes.bool,
PropTypes.func,
PropTypes.string
]),
filterFormatted: PropTypes.bool,
filterValue: PropTypes.func,
sort: PropTypes.string,
Expand Down

0 comments on commit cd93a3f

Please sign in to comment.