fix:拖拽列宽,滚动条动态改变;fix:两个滚动条联动bug;fix:拖拽追后一列超出内容隐藏
This commit is contained in:
parent
b65fae8676
commit
ff3b5196c3
|
@ -911,7 +911,7 @@ var Table = function (_Component) {
|
||||||
//显示表头滚动条
|
//显示表头滚动条
|
||||||
if (headerScroll) {
|
if (headerScroll) {
|
||||||
if (fixed) {
|
if (fixed) {
|
||||||
//内容少,不用显示滚动条
|
|
||||||
if (this.domWidthDiff <= 0) {
|
if (this.domWidthDiff <= 0) {
|
||||||
headStyle.marginBottom = scrollbarWidth + 'px';
|
headStyle.marginBottom = scrollbarWidth + 'px';
|
||||||
bodyStyle.marginBottom = '-' + scrollbarWidth + 'px';
|
bodyStyle.marginBottom = '-' + scrollbarWidth + 'px';
|
||||||
|
@ -1179,7 +1179,7 @@ var Table = function (_Component) {
|
||||||
// Prevent scrollTop setter trigger onScroll event
|
// Prevent scrollTop setter trigger onScroll event
|
||||||
// http://stackoverflow.com/q/1386696
|
// http://stackoverflow.com/q/1386696
|
||||||
|
|
||||||
if (e.target !== this.scrollTarget && this.scrollTarget !== headTable) {
|
if (e.currentTarget !== e.target) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e.target.scrollLeft !== this.lastScrollLeft) {
|
if (e.target.scrollLeft !== this.lastScrollLeft) {
|
||||||
|
|
|
@ -96,6 +96,7 @@ var TableHeader = function (_Component) {
|
||||||
contentTableHeader.style.overflowX = 'scroll';
|
contentTableHeader.style.overflowX = 'scroll';
|
||||||
fixedLeftHeaderTable && (fixedLeftHeaderTable.style.marginBottom = scrollbarWidth + "px");
|
fixedLeftHeaderTable && (fixedLeftHeaderTable.style.marginBottom = scrollbarWidth + "px");
|
||||||
fixedRighHeadertTable && (fixedRighHeadertTable.style.marginBottom = scrollbarWidth + "px");
|
fixedRighHeadertTable && (fixedRighHeadertTable.style.marginBottom = scrollbarWidth + "px");
|
||||||
|
//todo inner scroll-x去掉;outer marginbottom 设置成-15px】
|
||||||
} else {
|
} else {
|
||||||
contentTableHeader.style.overflowX = 'hidden';
|
contentTableHeader.style.overflowX = 'hidden';
|
||||||
fixedLeftHeaderTable && (fixedLeftHeaderTable.style.marginBottom = '0px');
|
fixedLeftHeaderTable && (fixedLeftHeaderTable.style.marginBottom = '0px');
|
||||||
|
|
|
@ -8640,8 +8640,6 @@ ul {
|
||||||
.u-table td {
|
.u-table td {
|
||||||
padding: 12px 8px;
|
padding: 12px 8px;
|
||||||
word-break: break-all; }
|
word-break: break-all; }
|
||||||
.u-table tr th:last-child {
|
|
||||||
overflow: hidden; }
|
|
||||||
.u-table tr.filterable th {
|
.u-table tr.filterable th {
|
||||||
padding-top: 4px;
|
padding-top: 4px;
|
||||||
padding-bottom: 4px; }
|
padding-bottom: 4px; }
|
||||||
|
@ -8662,6 +8660,8 @@ ul {
|
||||||
.u-table-bordered td {
|
.u-table-bordered td {
|
||||||
border-right: 1px solid rgb(233,233,233);
|
border-right: 1px solid rgb(233,233,233);
|
||||||
box-sizing: border-box; }
|
box-sizing: border-box; }
|
||||||
|
.u-table-drag-border tr th.th-can-not-drag {
|
||||||
|
overflow: hidden; }
|
||||||
.u-table-header {
|
.u-table-header {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: rgb(247,247,247);
|
background: rgb(247,247,247);
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -11001,8 +11001,7 @@
|
||||||
syncHover: true,
|
syncHover: true,
|
||||||
setRowHeight: function setRowHeight() {},
|
setRowHeight: function setRowHeight() {},
|
||||||
setRowParentIndex: function setRowParentIndex() {},
|
setRowParentIndex: function setRowParentIndex() {},
|
||||||
tabIndex: '0',
|
tabIndex: '0'
|
||||||
noExpandedRowKeys: []
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var Table = function (_Component) {
|
var Table = function (_Component) {
|
||||||
|
@ -11586,11 +11585,6 @@
|
||||||
if (rootIndex == -1) {
|
if (rootIndex == -1) {
|
||||||
index = i + lazyParentIndex;
|
index = i + lazyParentIndex;
|
||||||
}
|
}
|
||||||
var noexpandable = void 0;
|
|
||||||
if (props.noExpandedRowKeys.indexOf(key) >= 0) {
|
|
||||||
noexpandable = true;
|
|
||||||
isHiddenExpandIcon = true;
|
|
||||||
}
|
|
||||||
rst.push(_react2['default'].createElement(_TableRow2['default'], _extends({
|
rst.push(_react2['default'].createElement(_TableRow2['default'], _extends({
|
||||||
indent: indent,
|
indent: indent,
|
||||||
indentSize: props.indentSize,
|
indentSize: props.indentSize,
|
||||||
|
@ -11603,7 +11597,7 @@
|
||||||
visible: visible,
|
visible: visible,
|
||||||
expandRowByClick: expandRowByClick,
|
expandRowByClick: expandRowByClick,
|
||||||
onExpand: this.onExpanded,
|
onExpand: this.onExpanded,
|
||||||
expandable: !noexpandable && (childrenColumn || expandedRowRender),
|
expandable: childrenColumn || expandedRowRender,
|
||||||
expanded: isRowExpanded,
|
expanded: isRowExpanded,
|
||||||
clsPrefix: props.clsPrefix + '-row',
|
clsPrefix: props.clsPrefix + '-row',
|
||||||
childrenColumnName: childrenColumnName,
|
childrenColumnName: childrenColumnName,
|
||||||
|
@ -12036,7 +12030,7 @@
|
||||||
// Prevent scrollTop setter trigger onScroll event
|
// Prevent scrollTop setter trigger onScroll event
|
||||||
// http://stackoverflow.com/q/1386696
|
// http://stackoverflow.com/q/1386696
|
||||||
|
|
||||||
if (e.target !== this.scrollTarget && this.scrollTarget !== headTable) {
|
if (e.currentTarget !== e.target) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e.target.scrollLeft !== this.lastScrollLeft) {
|
if (e.target.scrollLeft !== this.lastScrollLeft) {
|
||||||
|
@ -13167,6 +13161,24 @@
|
||||||
|
|
||||||
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
|
var _this = _possibleConstructorReturn(this, _Component.call(this, props));
|
||||||
|
|
||||||
|
_this.optTableMargin = function (table, scrollbarWidth) {
|
||||||
|
if (table) {
|
||||||
|
table.style.marginBottom = scrollbarWidth + "px";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
_this.optTableScroll = function (table) {
|
||||||
|
var overflow = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
||||||
|
|
||||||
|
if (table) {
|
||||||
|
var innerTable = table.querySelector('.u-table-body-inner');
|
||||||
|
if (innerTable) {
|
||||||
|
overflow.x && (innerTable.style.overflowX = overflow.x);
|
||||||
|
overflow.y && (innerTable.style.overflowY = overflow.y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
_this.onLineMouseMove = function (e) {
|
_this.onLineMouseMove = function (e) {
|
||||||
var _this$props = _this.props,
|
var _this$props = _this.props,
|
||||||
clsPrefix = _this$props.clsPrefix,
|
clsPrefix = _this$props.clsPrefix,
|
||||||
|
@ -13194,30 +13206,43 @@
|
||||||
if (_this.fixedTable.cols) {
|
if (_this.fixedTable.cols) {
|
||||||
_this.fixedTable.cols[_this.drag.currIndex].style.width = newWidth + "px";
|
_this.fixedTable.cols[_this.drag.currIndex].style.width = newWidth + "px";
|
||||||
}
|
}
|
||||||
|
var oldTableWidth = parseInt(_this.table.table.style.width ? _this.table.table.style.width : _this.table.table.scrollWidth);
|
||||||
|
var newTableWidth = oldTableWidth + diff;
|
||||||
|
_this.table.table.style.width = newTableWidth; //改变table的width
|
||||||
|
|
||||||
|
var showScroll = contentDomWidth - newTableWidth - scrollbarWidth;
|
||||||
|
var fixedLeftHeaderTable = contentTable.querySelector('.u-table-fixed-left .u-table-header');
|
||||||
|
var fixedRighHeadertTable = contentTable.querySelector('.u-table-fixed-right .u-table-header');
|
||||||
|
var contentTableHeader = contentTable.querySelector('.u-table-scroll .u-table-header');
|
||||||
|
var fixedLeftBodyTable = contentTable.querySelector('.u-table-fixed-left .u-table-body-outer');
|
||||||
|
var fixedRightBodyTable = contentTable.querySelector('.u-table-fixed-right .u-table-body-outer');
|
||||||
|
|
||||||
//表头滚动条处理
|
//表头滚动条处理
|
||||||
if (headerScroll) {
|
if (headerScroll) {
|
||||||
var oldTableWidth = parseInt(_this.table.table.style.width ? _this.table.table.style.width : _this.table.table.scrollWidth);
|
|
||||||
var newTableWidth = oldTableWidth + diff;
|
|
||||||
_this.table.table.style.width = newTableWidth; //改变table的width
|
|
||||||
|
|
||||||
var showScroll = contentDomWidth - newTableWidth - scrollbarWidth;
|
|
||||||
// if(bordered){
|
|
||||||
// showScroll = showScroll -1;
|
|
||||||
// }
|
|
||||||
var fixedLeftHeaderTable = contentTable.querySelector('.u-table-fixed-left .u-table-header');
|
|
||||||
var fixedRighHeadertTable = contentTable.querySelector('.u-table-fixed-right .u-table-header');
|
|
||||||
var contentTableHeader = contentTable.querySelector('.u-table-scroll .u-table-header');
|
|
||||||
if (showScroll < 0) {
|
if (showScroll < 0) {
|
||||||
//找到固定列表格,设置表头的marginBottom值为scrollbarWidth;
|
//找到固定列表格,设置表头的marginBottom值为scrollbarWidth;
|
||||||
contentTableHeader.style.overflowX = 'scroll';
|
contentTableHeader.style.overflowX = 'scroll';
|
||||||
fixedLeftHeaderTable && (fixedLeftHeaderTable.style.marginBottom = scrollbarWidth + "px");
|
_this.optTableMargin(fixedLeftHeaderTable, scrollbarWidth);
|
||||||
fixedRighHeadertTable && (fixedRighHeadertTable.style.marginBottom = scrollbarWidth + "px");
|
_this.optTableMargin(fixedRighHeadertTable, scrollbarWidth);
|
||||||
|
// fixedLeftHeaderTable && (fixedLeftHeaderTable.style.marginBottom = scrollbarWidth + "px");
|
||||||
|
// fixedRighHeadertTable && (fixedRighHeadertTable.style.marginBottom = scrollbarWidth + "px");
|
||||||
//todo inner scroll-x去掉;outer marginbottom 设置成-15px】
|
//todo inner scroll-x去掉;outer marginbottom 设置成-15px】
|
||||||
} else {
|
} else {
|
||||||
contentTableHeader.style.overflowX = 'hidden';
|
contentTableHeader.style.overflowX = 'hidden';
|
||||||
fixedLeftHeaderTable && (fixedLeftHeaderTable.style.marginBottom = '0px');
|
_this.optTableMargin(fixedLeftHeaderTable, 0);
|
||||||
fixedRighHeadertTable && (fixedRighHeadertTable.style.marginBottom = '0px');
|
_this.optTableMargin(fixedRighHeadertTable, 0);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (showScroll < 0) {
|
||||||
|
_this.optTableMargin(fixedLeftBodyTable, '-' + scrollbarWidth);
|
||||||
|
_this.optTableMargin(fixedRightBodyTable, '-' + scrollbarWidth);
|
||||||
|
_this.optTableScroll(fixedLeftBodyTable, { x: 'scroll' });
|
||||||
|
_this.optTableScroll(fixedRightBodyTable, { x: 'scroll' });
|
||||||
|
} else {
|
||||||
|
_this.optTableMargin(fixedLeftBodyTable, 0);
|
||||||
|
_this.optTableMargin(fixedRightBodyTable, 0);
|
||||||
|
_this.optTableScroll(fixedLeftBodyTable, { x: 'auto' });
|
||||||
|
_this.optTableScroll(fixedRightBodyTable, { x: 'auto' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13577,6 +13602,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
*相关滚动条联动操作
|
||||||
|
*
|
||||||
|
* @memberof TableHeader
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调整列宽的move事件
|
* 调整列宽的move事件
|
||||||
|
|
File diff suppressed because one or more lines are too long
12
src/Table.js
12
src/Table.js
|
@ -84,8 +84,7 @@ const defaultProps = {
|
||||||
syncHover: true,
|
syncHover: true,
|
||||||
setRowHeight:()=>{},
|
setRowHeight:()=>{},
|
||||||
setRowParentIndex:()=>{},
|
setRowParentIndex:()=>{},
|
||||||
tabIndex:'0',
|
tabIndex:'0'
|
||||||
noExpandedRowKeys:[]
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Table extends Component {
|
class Table extends Component {
|
||||||
|
@ -594,11 +593,6 @@ class Table extends Component {
|
||||||
if(rootIndex ==-1){
|
if(rootIndex ==-1){
|
||||||
index = i+lazyParentIndex
|
index = i+lazyParentIndex
|
||||||
}
|
}
|
||||||
let noexpandable;
|
|
||||||
if(props.noExpandedRowKeys.indexOf(key) >= 0){
|
|
||||||
noexpandable = true;
|
|
||||||
isHiddenExpandIcon = true;
|
|
||||||
}
|
|
||||||
rst.push(
|
rst.push(
|
||||||
<TableRow
|
<TableRow
|
||||||
indent={indent}
|
indent={indent}
|
||||||
|
@ -612,7 +606,7 @@ class Table extends Component {
|
||||||
visible={visible}
|
visible={visible}
|
||||||
expandRowByClick={expandRowByClick}
|
expandRowByClick={expandRowByClick}
|
||||||
onExpand={this.onExpanded}
|
onExpand={this.onExpanded}
|
||||||
expandable={!noexpandable && (childrenColumn || expandedRowRender)}
|
expandable={childrenColumn || expandedRowRender}
|
||||||
expanded={isRowExpanded}
|
expanded={isRowExpanded}
|
||||||
clsPrefix={`${props.clsPrefix}-row`}
|
clsPrefix={`${props.clsPrefix}-row`}
|
||||||
childrenColumnName={childrenColumnName}
|
childrenColumnName={childrenColumnName}
|
||||||
|
@ -1014,7 +1008,7 @@ class Table extends Component {
|
||||||
const { headTable, bodyTable, fixedColumnsBodyLeft, fixedColumnsBodyRight } = this.refs;
|
const { headTable, bodyTable, fixedColumnsBodyLeft, fixedColumnsBodyRight } = this.refs;
|
||||||
// Prevent scrollTop setter trigger onScroll event
|
// Prevent scrollTop setter trigger onScroll event
|
||||||
// http://stackoverflow.com/q/1386696
|
// http://stackoverflow.com/q/1386696
|
||||||
if (e.target !== this.scrollTarget && this.scrollTarget !== headTable) {
|
if (e.currentTarget !== e.target) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e.target.scrollLeft !== this.lastScrollLeft) {
|
if (e.target.scrollLeft !== this.lastScrollLeft) {
|
||||||
|
|
|
@ -97,9 +97,7 @@ $checkbox-height:16px;
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
tr {
|
tr {
|
||||||
th:last-child{ //拖拽tag影响了表格整体宽度
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
&.filterable{
|
&.filterable{
|
||||||
th{
|
th{
|
||||||
padding-top: 4px;
|
padding-top: 4px;
|
||||||
|
@ -134,6 +132,13 @@ $checkbox-height:16px;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&-drag-border{
|
||||||
|
tr {
|
||||||
|
th.th-can-not-drag{ //拖拽tag影响了表格整体宽度
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
&-header {
|
&-header {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
background: $table-head-background-color;
|
background: $table-head-background-color;
|
||||||
|
|
|
@ -157,7 +157,31 @@ class TableHeader extends Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
*相关滚动条联动操作
|
||||||
|
*
|
||||||
|
* @memberof TableHeader
|
||||||
|
*/
|
||||||
|
optTableMargin =(table,scrollbarWidth)=>{
|
||||||
|
if(table){
|
||||||
|
table.style.marginBottom = scrollbarWidth + "px"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
optTableScroll = (table,overflow ={})=>{
|
||||||
|
if(table){
|
||||||
|
const innerTable = table.querySelector('.u-table-body-inner');
|
||||||
|
if(innerTable){
|
||||||
|
overflow.x && (innerTable.style.overflowX = overflow.x);
|
||||||
|
overflow.y && (innerTable.style.overflowY = overflow.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调整列宽的move事件
|
* 调整列宽的move事件
|
||||||
* @memberof TableHeader
|
* @memberof TableHeader
|
||||||
|
@ -182,31 +206,44 @@ class TableHeader extends Component {
|
||||||
if(this.fixedTable.cols){
|
if(this.fixedTable.cols){
|
||||||
this.fixedTable.cols[this.drag.currIndex].style.width = newWidth + "px";
|
this.fixedTable.cols[this.drag.currIndex].style.width = newWidth + "px";
|
||||||
}
|
}
|
||||||
|
let oldTableWidth = parseInt(this.table.table.style.width ?this.table.table.style.width:this.table.table.scrollWidth);
|
||||||
|
const newTableWidth = oldTableWidth + diff ;
|
||||||
|
this.table.table.style.width = newTableWidth;//改变table的width
|
||||||
|
|
||||||
|
let showScroll = contentDomWidth - newTableWidth - scrollbarWidth ;
|
||||||
|
const fixedLeftHeaderTable = contentTable.querySelector('.u-table-fixed-left .u-table-header') ;
|
||||||
|
const fixedRighHeadertTable = contentTable.querySelector('.u-table-fixed-right .u-table-header');
|
||||||
|
const contentTableHeader = contentTable.querySelector('.u-table-scroll .u-table-header');
|
||||||
|
const fixedLeftBodyTable = contentTable.querySelector('.u-table-fixed-left .u-table-body-outer') ;
|
||||||
|
const fixedRightBodyTable = contentTable.querySelector('.u-table-fixed-right .u-table-body-outer') ;
|
||||||
|
|
||||||
//表头滚动条处理
|
//表头滚动条处理
|
||||||
if(headerScroll){
|
if(headerScroll){
|
||||||
let oldTableWidth = parseInt(this.table.table.style.width ?this.table.table.style.width:this.table.table.scrollWidth);
|
|
||||||
const newTableWidth = oldTableWidth + diff ;
|
|
||||||
this.table.table.style.width = newTableWidth;//改变table的width
|
|
||||||
|
|
||||||
let showScroll = contentDomWidth - newTableWidth - scrollbarWidth ;
|
|
||||||
// if(bordered){
|
|
||||||
// showScroll = showScroll -1;
|
|
||||||
// }
|
|
||||||
const fixedLeftHeaderTable = contentTable.querySelector('.u-table-fixed-left .u-table-header') ;
|
|
||||||
const fixedRighHeadertTable = contentTable.querySelector('.u-table-fixed-right .u-table-header');
|
|
||||||
const contentTableHeader = contentTable.querySelector('.u-table-scroll .u-table-header');
|
|
||||||
if(showScroll < 0){
|
if(showScroll < 0){
|
||||||
//找到固定列表格,设置表头的marginBottom值为scrollbarWidth;
|
//找到固定列表格,设置表头的marginBottom值为scrollbarWidth;
|
||||||
contentTableHeader.style.overflowX = 'scroll';
|
contentTableHeader.style.overflowX = 'scroll';
|
||||||
fixedLeftHeaderTable && (fixedLeftHeaderTable.style.marginBottom = scrollbarWidth + "px");
|
this.optTableMargin(fixedLeftHeaderTable,scrollbarWidth);
|
||||||
fixedRighHeadertTable && (fixedRighHeadertTable.style.marginBottom = scrollbarWidth + "px");
|
this.optTableMargin(fixedRighHeadertTable,scrollbarWidth);
|
||||||
|
// fixedLeftHeaderTable && (fixedLeftHeaderTable.style.marginBottom = scrollbarWidth + "px");
|
||||||
|
// fixedRighHeadertTable && (fixedRighHeadertTable.style.marginBottom = scrollbarWidth + "px");
|
||||||
//todo inner scroll-x去掉;outer marginbottom 设置成-15px】
|
//todo inner scroll-x去掉;outer marginbottom 设置成-15px】
|
||||||
}else{
|
}else{
|
||||||
contentTableHeader.style.overflowX = 'hidden';
|
contentTableHeader.style.overflowX = 'hidden';
|
||||||
fixedLeftHeaderTable && (fixedLeftHeaderTable.style.marginBottom = '0px');
|
this.optTableMargin(fixedLeftHeaderTable,0);
|
||||||
fixedRighHeadertTable && (fixedRighHeadertTable.style.marginBottom = '0px');
|
this.optTableMargin(fixedRighHeadertTable,0);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
if(showScroll < 0){
|
||||||
|
this.optTableMargin(fixedLeftBodyTable,'-'+scrollbarWidth);
|
||||||
|
this.optTableMargin(fixedRightBodyTable,'-'+scrollbarWidth);
|
||||||
|
this.optTableScroll(fixedLeftBodyTable,{x:'scroll'});
|
||||||
|
this.optTableScroll(fixedRightBodyTable,{x:'scroll'});
|
||||||
|
}else{
|
||||||
|
this.optTableMargin(fixedLeftBodyTable,0);
|
||||||
|
this.optTableMargin(fixedRightBodyTable,0);
|
||||||
|
this.optTableScroll(fixedLeftBodyTable,{x:'auto'});
|
||||||
|
this.optTableScroll(fixedRightBodyTable,{x:'auto'});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue