fix: reset left/rightBodyRows when data changes
This commit is contained in:
parent
ffd42b97e6
commit
d6e16c2ef1
|
@ -398,6 +398,7 @@ var Table = function (_Component) {
|
|||
_this.leftColumnsLength; //左侧固定列的长度
|
||||
_this.centerColumnsLength; //非固定列的长度
|
||||
_this.columnsChildrenList = []; //复杂表头、所有叶子节点
|
||||
_this.dataChanged = false; // 数据是否改变
|
||||
return _this;
|
||||
}
|
||||
|
||||
|
@ -432,6 +433,7 @@ var Table = function (_Component) {
|
|||
showRowNum = _props.showRowNum;
|
||||
|
||||
if ('data' in nextProps) {
|
||||
this.dataChanged = JSON.stringify(this.props.data) !== JSON.stringify(nextProps.data);
|
||||
this.setState({
|
||||
data: nextProps.data
|
||||
});
|
||||
|
@ -1512,8 +1514,9 @@ var Table = function (_Component) {
|
|||
var headRows = this.headTable ? this.headTable.querySelectorAll('thead') : this.bodyTable.querySelectorAll('thead');
|
||||
var expandedRows = this.bodyTable.querySelectorAll('.' + clsPrefix + '-expanded-row') || [];
|
||||
var bodyRows = this.bodyTable.querySelectorAll('.' + clsPrefix + '-row') || [];
|
||||
var leftBodyRows = this.refs.fixedColumnsBodyLeft && this.refs.fixedColumnsBodyLeft.querySelectorAll('.' + clsPrefix + '-row') || [];
|
||||
var rightBodyRows = this.refs.fixedColumnsBodyRight && this.refs.fixedColumnsBodyRight.querySelectorAll('.' + clsPrefix + '-row') || [];
|
||||
var leftBodyRows = !this.dataChanged && this.refs.fixedColumnsBodyLeft && this.refs.fixedColumnsBodyLeft.querySelectorAll('.' + clsPrefix + '-row') || [];
|
||||
var rightBodyRows = !this.dataChanged && this.refs.fixedColumnsBodyRight && this.refs.fixedColumnsBodyRight.querySelectorAll('.' + clsPrefix + '-row') || [];
|
||||
this.dataChanged = false;
|
||||
var fixedColumnsHeadRowsHeight = [].map.call(headRows, function (row) {
|
||||
var height = headerHeight;
|
||||
if (headerHeight) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "bee-table",
|
||||
"version": "2.3.15-beta.8",
|
||||
"version": "2.3.15-beta.9",
|
||||
"description": "Table ui component for react",
|
||||
"keywords": [
|
||||
"react",
|
||||
|
|
|
@ -178,6 +178,7 @@ class Table extends Component {
|
|||
this.leftColumnsLength //左侧固定列的长度
|
||||
this.centerColumnsLength //非固定列的长度
|
||||
this.columnsChildrenList = [];//复杂表头、所有叶子节点
|
||||
this.dataChanged = false; // 数据是否改变
|
||||
}
|
||||
componentWillMount() {
|
||||
this.centerColumnsLength = this.columnManager.centerColumns().length
|
||||
|
@ -209,6 +210,7 @@ class Table extends Component {
|
|||
componentWillReceiveProps(nextProps) {
|
||||
let { hideDragHandle, rowDraggAble, showRowNum } = this.props;
|
||||
if ('data' in nextProps) {
|
||||
this.dataChanged = JSON.stringify(this.props.data) !== JSON.stringify(nextProps.data)
|
||||
this.setState({
|
||||
data: nextProps.data,
|
||||
});
|
||||
|
@ -1280,8 +1282,9 @@ class Table extends Component {
|
|||
this.bodyTable.querySelectorAll('thead');
|
||||
const expandedRows = this.bodyTable.querySelectorAll(`.${clsPrefix}-expanded-row`) || [];
|
||||
const bodyRows = this.bodyTable.querySelectorAll(`.${clsPrefix}-row`) || [];
|
||||
const leftBodyRows = this.refs.fixedColumnsBodyLeft && this.refs.fixedColumnsBodyLeft.querySelectorAll(`.${clsPrefix}-row`) || [];
|
||||
const rightBodyRows = this.refs.fixedColumnsBodyRight && this.refs.fixedColumnsBodyRight.querySelectorAll(`.${clsPrefix}-row`) || [];
|
||||
const leftBodyRows = !this.dataChanged && this.refs.fixedColumnsBodyLeft && this.refs.fixedColumnsBodyLeft.querySelectorAll(`.${clsPrefix}-row`) || [];
|
||||
const rightBodyRows = !this.dataChanged && this.refs.fixedColumnsBodyRight && this.refs.fixedColumnsBodyRight.querySelectorAll(`.${clsPrefix}-row`) || [];
|
||||
this.dataChanged = false
|
||||
const fixedColumnsHeadRowsHeight = [].map.call(
|
||||
headRows, row =>{
|
||||
let height = headerHeight;
|
||||
|
|
Loading…
Reference in New Issue