column动态计算后,scrollTop置为0

This commit is contained in:
wanghaoo 2018-10-17 17:16:23 +08:00
parent af91721d34
commit 5a998a13fb
6 changed files with 19 additions and 6 deletions

View File

@ -235,6 +235,10 @@ var Table = function (_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) {
//如果列变了对应的table的ScrollTop属性置为0
this.refs.bodyTable.scrollTop = 0;
}
} 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);
} }

View File

@ -192,8 +192,8 @@ function sum(Table) {
footerScroll: true, footerScroll: true,
columns: this.props.columns, columns: this.props.columns,
data: this.props.data, data: this.props.data,
footer: this.setFooterRender, footer: this.setFooterRender
originWidth: true // originWidth={true}
})); }));
}; };

8
dist/demo.js vendored
View File

@ -10803,6 +10803,10 @@
} }
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) {
//如果列变了对应的table的ScrollTop属性置为0
this.refs.bodyTable.scrollTop = 0;
}
} 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);
} }
@ -53712,8 +53716,8 @@
footerScroll: true, footerScroll: true,
columns: this.props.columns, columns: this.props.columns,
data: this.props.data, data: this.props.data,
footer: this.setFooterRender, footer: this.setFooterRender
originWidth: true // originWidth={true}
})); }));
}; };

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -156,6 +156,10 @@ 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){
//如果列变了对应的table的ScrollTop属性置为0
this.refs.bodyTable.scrollTop = 0;
}
} 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);
} }
@ -175,6 +179,7 @@ class Table extends Component {
this.computeTableWidth(); this.computeTableWidth();
} }
} }
componentWillUnmount() { componentWillUnmount() {

View File

@ -132,7 +132,7 @@ export default function sum(Table) {
columns={this.props.columns} columns={this.props.columns}
data={this.props.data} data={this.props.data}
footer={this.setFooterRender} footer={this.setFooterRender}
originWidth={true} // originWidth={true}
/> />
); );
} }