2.3.15-beta.6
This commit is contained in:
parent
e072df43fb
commit
f1dfb9c85f
|
@ -292,6 +292,17 @@ var Table = function (_Component) {
|
||||||
return Number(tdPaddingTop.replace('px', '')) + Number(tdPaddingBottom.replace('px', '')) + Number(tdBorderTop.replace('px', '')) + Number(tdBorderBottom.replace('px', ''));
|
return Number(tdPaddingTop.replace('px', '')) + Number(tdPaddingBottom.replace('px', '')) + Number(tdBorderTop.replace('px', '')) + Number(tdBorderBottom.replace('px', ''));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_this.getFlatRecords = function (data) {
|
||||||
|
var result = [];
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
result.push(data[i]);
|
||||||
|
if ((data[i].children || []).length) {
|
||||||
|
result = result.concat(_this.getFlatRecords(data[i].children));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
_this.clearBodyMouseLeaveTimer = function () {
|
_this.clearBodyMouseLeaveTimer = function () {
|
||||||
if (_this.bodyMouseLeaveTimmer) {
|
if (_this.bodyMouseLeaveTimmer) {
|
||||||
clearTimeout(_this.bodyMouseLeaveTimmer);
|
clearTimeout(_this.bodyMouseLeaveTimmer);
|
||||||
|
@ -1504,11 +1515,21 @@ var Table = function (_Component) {
|
||||||
}
|
}
|
||||||
return headerHeight ? height : parseInt(row.getBoundingClientRect().height) || 'auto';
|
return headerHeight ? height : parseInt(row.getBoundingClientRect().height) || 'auto';
|
||||||
});
|
});
|
||||||
|
var flatRecords = this.getFlatRecords(this.props.data || []);
|
||||||
var fixedColumnsBodyRowsHeight = [].map.call(bodyRows, function (row, index) {
|
var fixedColumnsBodyRowsHeight = [].map.call(bodyRows, function (row, index) {
|
||||||
var rsHeight = height;
|
var rsHeight = height;
|
||||||
if (bodyDisplayInRow && rsHeight) {
|
if (bodyDisplayInRow && rsHeight) {
|
||||||
return rsHeight;
|
return rsHeight;
|
||||||
} else {
|
} else {
|
||||||
|
var rowKey = row.getAttribute('data-row-key');
|
||||||
|
var record = flatRecords.find(function (record) {
|
||||||
|
return record.key === rowKey;
|
||||||
|
}) || {};
|
||||||
|
var leafKey = 'isleaf' in record ? 'isleaf' : '_isLeaf' in record ? '_isLeaf' : null; // ncc传递这俩属性区分是否是子节点
|
||||||
|
var isLeaf = leafKey && record[leafKey] === true;
|
||||||
|
if (isLeaf) {
|
||||||
|
return Number(Number(row.getBoundingClientRect().height).toFixed(2)) || 'auto';
|
||||||
|
}
|
||||||
// 为了提高性能,默认获取主表的高度,但是有的场景中固定列的高度比主表的高度高,所以提供此属性,会统计所有列的高度取最大的,设置
|
// 为了提高性能,默认获取主表的高度,但是有的场景中固定列的高度比主表的高度高,所以提供此属性,会统计所有列的高度取最大的,设置
|
||||||
// 内容折行显示,并又设置了 height 的情况下,也要获取主表高度
|
// 内容折行显示,并又设置了 height 的情况下,也要获取主表高度
|
||||||
if (heightConsistent || !bodyDisplayInRow && rsHeight) {
|
if (heightConsistent || !bodyDisplayInRow && rsHeight) {
|
||||||
|
|
|
@ -48201,6 +48201,17 @@
|
||||||
return Number(tdPaddingTop.replace('px', '')) + Number(tdPaddingBottom.replace('px', '')) + Number(tdBorderTop.replace('px', '')) + Number(tdBorderBottom.replace('px', ''));
|
return Number(tdPaddingTop.replace('px', '')) + Number(tdPaddingBottom.replace('px', '')) + Number(tdBorderTop.replace('px', '')) + Number(tdBorderBottom.replace('px', ''));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
_this.getFlatRecords = function (data) {
|
||||||
|
var result = [];
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
result.push(data[i]);
|
||||||
|
if ((data[i].children || []).length) {
|
||||||
|
result = result.concat(_this.getFlatRecords(data[i].children));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
_this.clearBodyMouseLeaveTimer = function () {
|
_this.clearBodyMouseLeaveTimer = function () {
|
||||||
if (_this.bodyMouseLeaveTimmer) {
|
if (_this.bodyMouseLeaveTimmer) {
|
||||||
clearTimeout(_this.bodyMouseLeaveTimmer);
|
clearTimeout(_this.bodyMouseLeaveTimmer);
|
||||||
|
@ -48423,7 +48434,7 @@
|
||||||
this.isShowScrollY();
|
this.isShowScrollY();
|
||||||
if (this.bodyTable) {
|
if (this.bodyTable) {
|
||||||
var currentOverflowX = window.getComputedStyle(this.bodyTable).overflowX;
|
var currentOverflowX = window.getComputedStyle(this.bodyTable).overflowX;
|
||||||
if ((!this.props.scroll.x || this.props.scroll.x === '100%') && currentOverflowX === 'scroll') {
|
if ((!this.props.scroll.x || this.props.scroll.x === '100%') && currentOverflowX !== 'hidden') {
|
||||||
this.bodyTable.style.overflowX = 'hidden';
|
this.bodyTable.style.overflowX = 'hidden';
|
||||||
}
|
}
|
||||||
if (this.props.scroll.x && this.props.scroll.x !== '100%' && currentOverflowX !== 'scroll') {
|
if (this.props.scroll.x && this.props.scroll.x !== '100%' && currentOverflowX !== 'scroll') {
|
||||||
|
@ -49138,6 +49149,8 @@
|
||||||
innerBodyStyle.overflowY = bodyStyle.overflowY || 'scroll';
|
innerBodyStyle.overflowY = bodyStyle.overflowY || 'scroll';
|
||||||
if (scroll.x && scroll.x !== '100%') {
|
if (scroll.x && scroll.x !== '100%') {
|
||||||
innerBodyStyle.overflowX = 'scroll';
|
innerBodyStyle.overflowX = 'scroll';
|
||||||
|
} else {
|
||||||
|
innerBodyStyle.overflowX = 'hidden';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
bodyStyle.maxHeight = bodyStyle.maxHeight || scroll.y;
|
bodyStyle.maxHeight = bodyStyle.maxHeight || scroll.y;
|
||||||
|
@ -49411,11 +49424,21 @@
|
||||||
}
|
}
|
||||||
return headerHeight ? height : parseInt(row.getBoundingClientRect().height) || 'auto';
|
return headerHeight ? height : parseInt(row.getBoundingClientRect().height) || 'auto';
|
||||||
});
|
});
|
||||||
|
var flatRecords = this.getFlatRecords(this.props.data || []);
|
||||||
var fixedColumnsBodyRowsHeight = [].map.call(bodyRows, function (row, index) {
|
var fixedColumnsBodyRowsHeight = [].map.call(bodyRows, function (row, index) {
|
||||||
var rsHeight = height;
|
var rsHeight = height;
|
||||||
if (bodyDisplayInRow && rsHeight) {
|
if (bodyDisplayInRow && rsHeight) {
|
||||||
return rsHeight;
|
return rsHeight;
|
||||||
} else {
|
} else {
|
||||||
|
var rowKey = row.getAttribute('data-row-key');
|
||||||
|
var record = flatRecords.find(function (record) {
|
||||||
|
return record.key === rowKey;
|
||||||
|
}) || {};
|
||||||
|
var leafKey = 'isleaf' in record ? 'isleaf' : '_isLeaf' in record ? '_isLeaf' : null; // ncc传递这俩属性区分是否是子节点
|
||||||
|
var isLeaf = leafKey && record[leafKey] === true;
|
||||||
|
if (isLeaf) {
|
||||||
|
return Number(Number(row.getBoundingClientRect().height).toFixed(2)) || 'auto';
|
||||||
|
}
|
||||||
// 为了提高性能,默认获取主表的高度,但是有的场景中固定列的高度比主表的高度高,所以提供此属性,会统计所有列的高度取最大的,设置
|
// 为了提高性能,默认获取主表的高度,但是有的场景中固定列的高度比主表的高度高,所以提供此属性,会统计所有列的高度取最大的,设置
|
||||||
// 内容折行显示,并又设置了 height 的情况下,也要获取主表高度
|
// 内容折行显示,并又设置了 height 的情况下,也要获取主表高度
|
||||||
if (heightConsistent || !bodyDisplayInRow && rsHeight) {
|
if (heightConsistent || !bodyDisplayInRow && rsHeight) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "bee-table",
|
"name": "bee-table",
|
||||||
"version": "2.3.15-beta.5",
|
"version": "2.3.15-beta.6",
|
||||||
"description": "Table ui component for react",
|
"description": "Table ui component for react",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"react",
|
"react",
|
||||||
|
|
19
src/Table.js
19
src/Table.js
|
@ -1255,6 +1255,17 @@ class Table extends Component {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getFlatRecords = data => {
|
||||||
|
var result = []
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
result.push(data[i])
|
||||||
|
if ((data[i].children || []).length) {
|
||||||
|
result = result.concat(this.getFlatRecords(data[i].children))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result
|
||||||
|
};
|
||||||
|
|
||||||
syncFixedTableRowHeight() {
|
syncFixedTableRowHeight() {
|
||||||
//this.props.height、headerHeight分别为用户传入的行高和表头高度,如果有值,所有行的高度都是固定的,主要为了避免在千行数据中有固定列时获取行高度有问题
|
//this.props.height、headerHeight分别为用户传入的行高和表头高度,如果有值,所有行的高度都是固定的,主要为了避免在千行数据中有固定列时获取行高度有问题
|
||||||
const { clsPrefix, height, headerHeight,columns,heightConsistent, bodyDisplayInRow } = this.props;
|
const { clsPrefix, height, headerHeight,columns,heightConsistent, bodyDisplayInRow } = this.props;
|
||||||
|
@ -1273,12 +1284,20 @@ class Table extends Component {
|
||||||
}
|
}
|
||||||
return headerHeight ? height : (parseInt(row.getBoundingClientRect().height) || 'auto')}
|
return headerHeight ? height : (parseInt(row.getBoundingClientRect().height) || 'auto')}
|
||||||
);
|
);
|
||||||
|
const flatRecords = this.getFlatRecords(this.props.data || [])
|
||||||
const fixedColumnsBodyRowsHeight = [].map.call(
|
const fixedColumnsBodyRowsHeight = [].map.call(
|
||||||
bodyRows, (row,index) =>{
|
bodyRows, (row,index) =>{
|
||||||
let rsHeight = height;
|
let rsHeight = height;
|
||||||
if(bodyDisplayInRow && rsHeight){
|
if(bodyDisplayInRow && rsHeight){
|
||||||
return rsHeight;
|
return rsHeight;
|
||||||
}else{
|
}else{
|
||||||
|
const rowKey = row.getAttribute('data-row-key')
|
||||||
|
const record = flatRecords.find(record => record.key === rowKey) || {}
|
||||||
|
const leafKey = 'isleaf' in record ? 'isleaf' : '_isLeaf' in record ? '_isLeaf' : null // ncc传递这俩属性区分是否是子节点
|
||||||
|
const isLeaf = leafKey && record[leafKey] === true
|
||||||
|
if (isLeaf) {
|
||||||
|
return Number((Number(row.getBoundingClientRect().height)).toFixed(2)) || 'auto';
|
||||||
|
}
|
||||||
// 为了提高性能,默认获取主表的高度,但是有的场景中固定列的高度比主表的高度高,所以提供此属性,会统计所有列的高度取最大的,设置
|
// 为了提高性能,默认获取主表的高度,但是有的场景中固定列的高度比主表的高度高,所以提供此属性,会统计所有列的高度取最大的,设置
|
||||||
// 内容折行显示,并又设置了 height 的情况下,也要获取主表高度
|
// 内容折行显示,并又设置了 height 的情况下,也要获取主表高度
|
||||||
if(heightConsistent || (!bodyDisplayInRow && rsHeight)){
|
if(heightConsistent || (!bodyDisplayInRow && rsHeight)){
|
||||||
|
|
Loading…
Reference in New Issue