’columns宽度不同时重置scrollTop‘

This commit is contained in:
wanghaoo 2018-10-24 21:58:58 +08:00
parent ba8837b04c
commit 059414bfae
5 changed files with 1425 additions and 952 deletions

2
dist/demo.css vendored
View File

@ -8501,7 +8501,7 @@ ul {
.u-table-row-expand-icon, .u-table-expanded-row-expand-icon { .u-table-row-expand-icon, .u-table-expanded-row-expand-icon {
cursor: pointer; cursor: pointer;
display: inline-block; display: inline-block;
margin-right: 10px; margin-right: 0px;
width: 16px; width: 16px;
height: 16px; height: 16px;
text-align: center; text-align: center;

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

2239
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -68,6 +68,7 @@ const defaultProps = {
rowRef: () => null, rowRef: () => null,
getBodyWrapper: body => body, getBodyWrapper: body => body,
emptyText: () => 'No Data', emptyText: () => 'No Data',
columns:[],
minColumnWidth: 80 minColumnWidth: 80
}; };
@ -156,10 +157,11 @@ class Table extends Component {
} }
if (nextProps.columns && nextProps.columns !== this.props.columns) { if (nextProps.columns && nextProps.columns !== this.props.columns) {
this.columnManager.reset(nextProps.columns); this.columnManager.reset(nextProps.columns);
if (this.refs && this.refs.bodyTable) { if(nextProps.columns.length !== this.props.length && this.refs && this.refs.bodyTable){
//如果列变了对应的table的ScrollTop属性置为0 this.refs.fixedColumnsBodyLeft && ( this.refs.fixedColumnsBodyLeft.scrollTop = this.refs.bodyTable.scrollTop);
this.refs.bodyTable.scrollTop = 0; this.refs.fixedColumnsBodyRight && ( this.refs.fixedColumnsBodyRight.scrollTop = this.refs.bodyTable.scrollTop);
} }
} else if (nextProps.children !== this.props.children) { } else if (nextProps.children !== this.props.children) {
this.columnManager.reset(null, nextProps.children); this.columnManager.reset(null, nextProps.children);
} }