Table: current row will set to the row which has the same row-key when data changes(#3023) (#13200)

pull/13257/head
Harlan 2018-10-31 16:42:34 +08:00 committed by hetech
parent bc26ab6ba5
commit 0d526b8371
1 changed files with 14 additions and 0 deletions

View File

@ -597,6 +597,20 @@ TableStore.prototype.updateCurrentRow = function() {
const oldCurrentRow = states.currentRow; const oldCurrentRow = states.currentRow;
if (data.indexOf(oldCurrentRow) === -1) { if (data.indexOf(oldCurrentRow) === -1) {
if (states.rowKey && oldCurrentRow) {
let newCurrentRow = null;
for (let i = 0; i < data.length; i++) {
const item = data[i];
if (item && item[states.rowKey] === oldCurrentRow[states.rowKey]) {
newCurrentRow = item;
break;
}
}
if (newCurrentRow) {
states.currentRow = newCurrentRow;
return;
}
}
states.currentRow = null; states.currentRow = null;
if (states.currentRow !== oldCurrentRow) { if (states.currentRow !== oldCurrentRow) {