bugfix:修复rowKey传递参数不正确的问题

This commit is contained in:
kvkens 2018-10-24 14:05:50 +08:00
parent 77fce73e59
commit 872c3f8bbb
3 changed files with 16 additions and 10 deletions

View File

@ -250,7 +250,7 @@
.u-table-row-expand-icon, .u-table-expanded-row-expand-icon { .u-table-row-expand-icon, .u-table-expanded-row-expand-icon {
cursor: pointer; cursor: pointer;
display: inline-block; display: inline-block;
margin-right: 10px; margin-right: 0px;
width: 16px; width: 16px;
height: 16px; height: 16px;
text-align: center; text-align: center;

View File

@ -920,8 +920,10 @@ var Table = function (_Component) {
Table.prototype.findExpandedRow = function findExpandedRow(record, index) { Table.prototype.findExpandedRow = function findExpandedRow(record, index) {
var _this4 = this; var _this4 = this;
var rows = this.getExpandedRows().filter(function (i) { //const rows = this.getExpandedRows().filter(i => i === this.getRowKey(record, index));
return i === _this4.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]; return rows[0];
}; };

View File

@ -156,7 +156,7 @@ class Table extends Component {
} }
if (nextProps.columns && nextProps.columns !== this.props.columns) { if (nextProps.columns && nextProps.columns !== this.props.columns) {
this.columnManager.reset(nextProps.columns); this.columnManager.reset(nextProps.columns);
if(this.refs && this.refs.bodyTable){ if (this.refs && this.refs.bodyTable) {
//如果列变了对应的table的ScrollTop属性置为0 //如果列变了对应的table的ScrollTop属性置为0
this.refs.bodyTable.scrollTop = 0; this.refs.bodyTable.scrollTop = 0;
} }
@ -175,7 +175,7 @@ class Table extends Component {
this.syncFixedTableRowHeight(); 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(); this.computeTableWidth();
} }
@ -297,7 +297,7 @@ class Table extends Component {
{...dragBorder} {...dragBorder}
minColumnWidth={minColumnWidth} minColumnWidth={minColumnWidth}
contentWidthDiff={contentWidthDiff} contentWidthDiff={contentWidthDiff}
contentWidth = {this.contentWidth} contentWidth={this.contentWidth}
lastShowIndex={this.state.lastShowIndex} lastShowIndex={this.state.lastShowIndex}
clsPrefix={clsPrefix} clsPrefix={clsPrefix}
rows={rows} rows={rows}
@ -803,7 +803,11 @@ class Table extends Component {
} }
findExpandedRow(record, index) { 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]; return rows[0];
} }