From 5ba0648eb2631f014aaf381a5976918b582ed88e Mon Sep 17 00:00:00 2001 From: jonyshi Date: Mon, 5 Aug 2019 21:32:15 +0800 Subject: [PATCH] =?UTF-8?q?=20=E4=BF=AE=E5=A4=8Dtitle=20=E4=B8=BAdom?= =?UTF-8?q?=E6=97=B6,=E4=BA=A4=E6=8D=A2=E5=88=97=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/TableHeader.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/TableHeader.js b/src/TableHeader.js index 078afdc..2b75c98 100644 --- a/src/TableHeader.js +++ b/src/TableHeader.js @@ -197,8 +197,8 @@ class TableHeader extends Component { let event = Event.getEvent(e) , targetEvent = Event.getTarget(event); const { clsPrefix, contentTable,lastShowIndex } = this.props; - let currentElement = this.getOnLineObject(targetEvent); - // let currentElement = this.getTargetToTh(targetEvent); + // let currentElement = this.getOnLineObject(targetEvent); + let currentElement = this.getTargetToType(targetEvent); if(!currentElement)return; let type = currentElement.getAttribute('data-type'); if(!this.props.dragborder && !this.props.draggable)return; @@ -246,6 +246,19 @@ class TableHeader extends Component { return (tableWidth-offWidth); } + /** + * 根据当前节点查找到有data-type类型的容器返回。 + * @memberof TableHeader + */ + getTargetToType = (targetEvent) => { + let tag = targetEvent; + if(targetEvent && !targetEvent.getAttribute("data-type")){ + tag = this.getTargetToType(targetEvent.parentElement); + } + return tag; + } + + /** * 判断当前的target 是否是 th,如果不是,直接递归查找。 * @memberof TableHeader