This commit is contained in:
AllenFang
2018-09-01 14:52:29 +08:00
parent 8d62261983
commit 849d9af8c4
2 changed files with 14 additions and 4 deletions

View File

@@ -11,9 +11,18 @@ class Cell extends Component {
}
shouldComponentUpdate(nextProps) {
const shouldUpdate =
_.get(this.props.row, this.props.column.dataField)
!== _.get(nextProps.row, nextProps.column.dataField) ||
let shouldUpdate = false;
if (nextProps.column.isDummyField) {
shouldUpdate = !_.isEqual(this.props.row, nextProps.row);
} else {
shouldUpdate =
_.get(this.props.row, this.props.column.dataField)
!== _.get(nextProps.row, nextProps.column.dataField);
}
if (shouldUpdate) return true;
shouldUpdate =
this.props.column.hidden !== nextProps.column.hidden ||
this.props.rowIndex !== nextProps.rowIndex ||
this.props.columnIndex !== nextProps.columnIndex ||
@@ -64,7 +73,7 @@ class Cell extends Component {
formatExtraData
} = column;
const attrs = { ...rest };
let content = _.get(row, dataField);
let content = column.isDummyField ? null : _.get(row, dataField);
if (formatter) {
content = column.formatter(content, row, rowIndex, formatExtraData);

View File

@@ -114,6 +114,7 @@ HeaderCell.propTypes = {
column: PropTypes.shape({
dataField: PropTypes.string.isRequired,
text: PropTypes.string.isRequired,
isDummyField: PropTypes.bool,
hidden: PropTypes.bool,
headerFormatter: PropTypes.func,
formatter: PropTypes.func,