From 2560ff4697cbb45d80dfe5921777ea2fc3907a51 Mon Sep 17 00:00:00 2001 From: jonyshi Date: Wed, 23 Jan 2019 11:43:59 +0800 Subject: [PATCH] =?UTF-8?q?=20=E6=96=B0=E5=A2=9E=20|=20onDropBorder=20|=20?= =?UTF-8?q?=E6=8B=96=E6=8B=BD=E9=87=8A=E6=94=BE=E5=9B=9E=E8=B0=83=E5=87=BD?= =?UTF-8?q?=E6=95=B0(=E8=B0=83=E6=95=B4=E5=88=97=E5=AE=BD)=20|=20function?= =?UTF-8?q?=20|=20(e)=20=3D>=20{}=20|?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- demo/demolist/Demo23.js | 4 ++++ docs/mixin.md | 4 +++- src/Table.js | 4 ++-- src/TableHeader.js | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/demo/demolist/Demo23.js b/demo/demolist/Demo23.js index 49b6e8b..2086efb 100644 --- a/demo/demolist/Demo23.js +++ b/demo/demolist/Demo23.js @@ -60,6 +60,10 @@ class Demo23 extends Component { return { + console.log("调整列宽后触发事件"); + }} />; } } diff --git a/docs/mixin.md b/docs/mixin.md index 7270baf..f355da2 100644 --- a/docs/mixin.md +++ b/docs/mixin.md @@ -101,7 +101,9 @@ const SumTable = sum(Table); | ------ | ---------- | -------- | ---- | | dragborder | 拖拽调整列宽度 | boolean | false | | draggable | 拖拽交换列 | boolean | false | -| onDrop | 拖拽释放回调函数 | function | () => {} | +| onDrop | 拖拽释放回调函数(交换列) | function | () => {} | +| onDropBorder | 拖拽释放回调函数(调整列宽) | function | (e) => {} | + #### 使用 diff --git a/src/Table.js b/src/Table.js index ab5ddf9..e70ff73 100644 --- a/src/Table.js +++ b/src/Table.js @@ -318,7 +318,7 @@ class Table extends Component { getHeader(columns, fixed) { const { filterDelay, onFilterChange, onFilterClear, filterable, showHeader, expandIconAsCell, clsPrefix, onDragStart, onDragEnter, onDragOver, onDrop, draggable, - onMouseDown, onMouseMove, onMouseUp, dragborder, onThMouseMove, dragborderKey, minColumnWidth, headerHeight,afterDragColWidth,headerScroll ,bordered} = this.props; + onMouseDown, onMouseMove, onMouseUp, dragborder, onThMouseMove, dragborderKey, minColumnWidth, headerHeight,afterDragColWidth,headerScroll ,bordered,onDropBorder} = this.props; const rows = this.getHeaderRows(columns); if (expandIconAsCell && fixed !== 'right') { rows[0].unshift({ @@ -331,7 +331,7 @@ class Table extends Component { const trStyle = headerHeight&&!fixed ? { height: headerHeight } : (fixed ? this.getHeaderRowStyle(columns, rows) : null); let drop = draggable ? { onDragStart, onDragOver, onDrop, onDragEnter, draggable } : {}; - let dragBorder = dragborder ? { onMouseDown, onMouseMove, onMouseUp, dragborder, onThMouseMove, dragborderKey } : {}; + let dragBorder = dragborder ? { onMouseDown, onMouseMove, onMouseUp, dragborder, onThMouseMove, dragborderKey,onDropBorder } : {}; let contentWidthDiff = 0; //非固定表格,宽度不够时自动扩充 if (!fixed) { diff --git a/src/TableHeader.js b/src/TableHeader.js index 0bf48a4..18f0185 100644 --- a/src/TableHeader.js +++ b/src/TableHeader.js @@ -235,6 +235,7 @@ class TableHeader extends Component { */ onLineMouseUp = (event) => { this.clearDragBorder(event); + this.props.onDropBorder(event) }; /**