|
|
@@ -90,7 +90,7 @@ class TableModel extends React.Component {
|
|
|
let title = node.getElementsByClassName('rc-table-title')[0] || { offsetHeight: 0 };
|
|
|
let thead = node.getElementsByClassName('rc-table-thead')[0];
|
|
|
this.cHeight = node.offsetHeight - title.offsetHeight;
|
|
|
- let trHeight = (this.cHeight) / (this.rowCount + 1);
|
|
|
+ let trHeight = (this.cHeight) / (this.rowCount);
|
|
|
let trFontSize = pageSize ? `${fontSize/.6 > trHeight ? trHeight * .6 : fontSize}px` : `${trHeight * .6}px`;
|
|
|
// let trFontSize = `${fontSize}px`;
|
|
|
thead.style.fontSize = trFontSize;
|
|
|
@@ -146,21 +146,24 @@ class TableModel extends React.Component {
|
|
|
*/
|
|
|
splitData() {
|
|
|
const { fontSize, pageSize } = this.newProps;
|
|
|
- let node = this.refs.body;
|
|
|
var allTitle = document.getElementsByClassName('rc-title')[0] || { offsetHeight: 0 };
|
|
|
+ let node = this.refs.body;
|
|
|
+ // 存在title与否会导致计算高度不一致,这里做一个差异补偿
|
|
|
+ let nHeight = (node.offsetHeight==window.innerHeight?
|
|
|
+ (allTitle.offsetHeight>0?(node.offsetHeight-allTitle.offsetHeight):node.offsetHeight):
|
|
|
+ (allTitle.offsetHeight==0?window.innerHeight:node.offsetHeight));
|
|
|
let title = node.getElementsByClassName('rc-table-title')[0] || { offsetHeight: 0 };
|
|
|
let thead = node.getElementsByClassName('rc-table-thead')[0];
|
|
|
- // 存在title与否会导致计算高度不一致,这里做一个差异补偿
|
|
|
- this.cHeight = node.offsetHeight - title.offsetHeight - thead.offsetHeight - (node.offsetHeight==window.innerHeight?allTitle.offsetHeight:(node.offsetHeight<window.innerHeight?(node.offsetHeight-window.innerHeight+allTitle.offsetHeight):0));
|
|
|
+ this.cHeight = nHeight - title.offsetHeight;
|
|
|
this.cWidth = node.offsetWidth;
|
|
|
- this.rowCount = pageSize || Math.round(this.cHeight / (fontSize / .6));
|
|
|
+ this.rowCount = pageSize ? (pageSize + 1) : Math.round(this.cHeight / (fontSize / .6)); // 这个rowCount是包含了head的
|
|
|
this.rowHeight = this.cHeight / this.rowCount;
|
|
|
let a = this.newProps.data;
|
|
|
let result = [];
|
|
|
let j = 0;
|
|
|
for (let i = 0; i < a.length; i = i + j) {
|
|
|
let arr = [];
|
|
|
- for (j = 0; j < this.rowCount && a[i + j]; j++) {
|
|
|
+ for (j = 0; j < this.rowCount-1 && a[i + j]; j++) { // rowCount需要减掉head
|
|
|
arr.push(a[i + j]);
|
|
|
}
|
|
|
result.push(arr);
|