From 872c3f8bbbdbfbd27a3570bf5933b9a234e6a668 Mon Sep 17 00:00:00 2001 From: kvkens Date: Wed, 24 Oct 2018 14:05:50 +0800 Subject: [PATCH] =?UTF-8?q?bugfix:=E4=BF=AE=E5=A4=8DrowKey=E4=BC=A0?= =?UTF-8?q?=E9=80=92=E5=8F=82=E6=95=B0=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/Table.css | 2 +- build/Table.js | 6 ++++-- src/Table.js | 18 +++++++++++------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/build/Table.css b/build/Table.css index da1cffb..c0cf85e 100644 --- a/build/Table.css +++ b/build/Table.css @@ -250,7 +250,7 @@ .u-table-row-expand-icon, .u-table-expanded-row-expand-icon { cursor: pointer; display: inline-block; - margin-right: 10px; + margin-right: 0px; width: 16px; height: 16px; text-align: center; diff --git a/build/Table.js b/build/Table.js index 1f9b49a..87fa58e 100644 --- a/build/Table.js +++ b/build/Table.js @@ -920,8 +920,10 @@ var Table = function (_Component) { Table.prototype.findExpandedRow = function findExpandedRow(record, index) { var _this4 = this; - var rows = this.getExpandedRows().filter(function (i) { - return i === _this4.getRowKey(record, index); + //const rows = this.getExpandedRows().filter(i => i === this.getRowKey(record, index)); + //修复rowKey index问题 By Kvkens 2018-10-24 13:38:38 + var rows = this.getExpandedRows().filter(function (item, i) { + i === _this4.getRowKey(record, index) || item === _this4.getRowKey(record, index); }); return rows[0]; }; diff --git a/src/Table.js b/src/Table.js index 85d19ae..113af1b 100644 --- a/src/Table.js +++ b/src/Table.js @@ -156,9 +156,9 @@ class Table extends Component { } if (nextProps.columns && nextProps.columns !== this.props.columns) { this.columnManager.reset(nextProps.columns); - if(this.refs && this.refs.bodyTable){ - //如果列变了,对应的table的ScrollTop属性置为0 - this.refs.bodyTable.scrollTop = 0; + if (this.refs && this.refs.bodyTable) { + //如果列变了,对应的table的ScrollTop属性置为0 + this.refs.bodyTable.scrollTop = 0; } } else if (nextProps.children !== this.props.children) { this.columnManager.reset(null, nextProps.children); @@ -175,7 +175,7 @@ class Table extends Component { this.syncFixedTableRowHeight(); } //适应模态框中表格、以及父容器宽度变化的情况 - if(typeof (this.props.scroll.x) !== 'number' && this.contentTable.getBoundingClientRect().width !== this.contentDomWidth){ + if (typeof (this.props.scroll.x) !== 'number' && this.contentTable.getBoundingClientRect().width !== this.contentDomWidth) { this.computeTableWidth(); } @@ -198,7 +198,7 @@ class Table extends Component { // this.preContentDomWidth = this.contentDomWidth; //计算总表格宽度、根据表格宽度和各列的宽度和比较,重置最后一列 this.contentDomWidth = this.contentTable.getBoundingClientRect().width//表格容器宽度 - + this.contentWidth = this.contentDomWidth;//默认与容器宽度一样 if (typeof (setWidthParam) == 'string' && setWidthParam.indexOf('%')) { this.contentWidth = this.contentWidth * parseInt(setWidthParam) / 100 @@ -297,7 +297,7 @@ class Table extends Component { {...dragBorder} minColumnWidth={minColumnWidth} contentWidthDiff={contentWidthDiff} - contentWidth = {this.contentWidth} + contentWidth={this.contentWidth} lastShowIndex={this.state.lastShowIndex} clsPrefix={clsPrefix} rows={rows} @@ -803,7 +803,11 @@ class Table extends Component { } findExpandedRow(record, index) { - const rows = this.getExpandedRows().filter(i => i === this.getRowKey(record, index)); + //const rows = this.getExpandedRows().filter(i => i === this.getRowKey(record, index)); + //修复rowKey index问题 By Kvkens 2018-10-24 13:38:38 + const rows = this.getExpandedRows().filter((item, i) => { + i === this.getRowKey(record, index) || item === this.getRowKey(record, index) + }); return rows[0]; }