表格列宽度支持百分比

This commit is contained in:
wanghaoo 2018-11-20 13:33:07 +08:00
parent 969b831528
commit 42b9ec7f2c
3 changed files with 22 additions and 17 deletions

18
dist/demo.js vendored
View File

@ -10846,9 +10846,7 @@
//如果用户传了scroll.x按用户传的为主 //如果用户传了scroll.x按用户传的为主
var setWidthParam = this.props.scroll.x; var setWidthParam = this.props.scroll.x;
var computeObj = this.columnManager.getColumnWidth(this.contentWidth);
var lastShowIndex = computeObj.lastShowIndex;
this.computeWidth = computeObj.computeWidth;
if (typeof setWidthParam == 'number') { if (typeof setWidthParam == 'number') {
var numSetWidthParam = parseInt(setWidthParam); var numSetWidthParam = parseInt(setWidthParam);
this.contentWidth = numSetWidthParam; this.contentWidth = numSetWidthParam;
@ -10858,11 +10856,15 @@
this.contentDomWidth = this.contentTable.getBoundingClientRect().width; //表格容器宽度 this.contentDomWidth = this.contentTable.getBoundingClientRect().width; //表格容器宽度
this.contentWidth = this.contentDomWidth; //默认与容器宽度一样 this.contentWidth = this.contentDomWidth; //默认与容器宽度一样
this.domWidthDiff = this.contentDomWidth - this.computeWidth; }
if (typeof setWidthParam == 'string' && setWidthParam.indexOf('%')) { var computeObj = this.columnManager.getColumnWidth(this.contentWidth);
this.contentWidth = this.contentWidth * parseInt(setWidthParam) / 100; var lastShowIndex = computeObj.lastShowIndex;
this.domWidthDiff = this.contentDomWidth - this.contentWidth; this.computeWidth = computeObj.computeWidth;
}
this.domWidthDiff = this.contentDomWidth - this.computeWidth;
if (typeof setWidthParam == 'string' && setWidthParam.indexOf('%')) {
this.contentWidth = this.contentWidth * parseInt(setWidthParam) / 100;
this.domWidthDiff = this.contentDomWidth - this.contentWidth;
} }
if (this.computeWidth < this.contentWidth) { if (this.computeWidth < this.contentWidth) {

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -203,9 +203,7 @@ class Table extends Component {
//如果用户传了scroll.x按用户传的为主 //如果用户传了scroll.x按用户传的为主
let setWidthParam = this.props.scroll.x let setWidthParam = this.props.scroll.x
const computeObj = this.columnManager.getColumnWidth(this.contentWidth);
let lastShowIndex = computeObj.lastShowIndex;
this.computeWidth = computeObj.computeWidth;
if (typeof (setWidthParam) == 'number') { if (typeof (setWidthParam) == 'number') {
let numSetWidthParam = parseInt(setWidthParam); let numSetWidthParam = parseInt(setWidthParam);
this.contentWidth = numSetWidthParam; this.contentWidth = numSetWidthParam;
@ -215,11 +213,16 @@ class Table extends Component {
this.contentDomWidth = this.contentTable.getBoundingClientRect().width//表格容器宽度 this.contentDomWidth = this.contentTable.getBoundingClientRect().width//表格容器宽度
this.contentWidth = this.contentDomWidth;//默认与容器宽度一样 this.contentWidth = this.contentDomWidth;//默认与容器宽度一样
this.domWidthDiff = this.contentDomWidth - this.computeWidth;
if (typeof (setWidthParam) == 'string' && setWidthParam.indexOf('%')) { }
this.contentWidth = this.contentWidth * parseInt(setWidthParam) / 100; const computeObj = this.columnManager.getColumnWidth(this.contentWidth);
this.domWidthDiff = this.contentDomWidth - this.contentWidth; let lastShowIndex = computeObj.lastShowIndex;
} this.computeWidth = computeObj.computeWidth;
this.domWidthDiff = this.contentDomWidth - this.computeWidth;
if (typeof (setWidthParam) == 'string' && setWidthParam.indexOf('%')) {
this.contentWidth = this.contentWidth * parseInt(setWidthParam) / 100;
this.domWidthDiff = this.contentDomWidth - this.contentWidth;
} }
if (this.computeWidth < this.contentWidth) { if (this.computeWidth < this.contentWidth) {