Skip to content

Commit 265be8f

Browse files
committed
fix: better way to select cells after sorted
1 parent 8d1fb87 commit 265be8f

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

src/cellmanager.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,6 @@ export default class CellManager {
333333

334334
_selectArea($cell1, $cell2) {
335335
if ($cell1 === $cell2) return false;
336-
337336
const cells = this.getCellsInRange($cell1, $cell2);
338337
if (!cells) return false;
339338

@@ -346,7 +345,7 @@ export default class CellManager {
346345
}
347346

348347
getCellsInRange($cell1, $cell2) {
349-
let colIndex1, rowIndex1, colIndex2, rowIndex2;
348+
let colIndex1, rowIndex1, colIndex2, rowIndex2, sortedColumns;
350349

351350
if (typeof $cell1 === 'number') {
352351
[colIndex1, rowIndex1, colIndex2, rowIndex2] = arguments;
@@ -360,9 +359,18 @@ export default class CellManager {
360359
const cell2 = $.data($cell2);
361360

362361
colIndex1 = +cell1.colIndex;
363-
rowIndex1 = +cell1.rowIndex;
364362
colIndex2 = +cell2.colIndex;
365-
rowIndex2 = +cell2.rowIndex;
363+
if(this.datamanager.getColumn(colIndex1).sortOrder != "none" || this.datamanager.getColumn(colIndex2).sortOrder != "none"){
364+
sortedColumns = true;
365+
rowIndex1 = this.datamanager.rowViewOrder.indexOf(parseInt(cell1.rowIndex))
366+
rowIndex2 = this.datamanager.rowViewOrder.indexOf(parseInt(cell2.rowIndex))
367+
}else{
368+
rowIndex1 = +cell1.rowIndex;
369+
rowIndex2 = +cell2.rowIndex;
370+
}
371+
372+
373+
366374
}
367375

368376
if (rowIndex1 > rowIndex2) {
@@ -394,7 +402,9 @@ export default class CellManager {
394402
}
395403
colIndex = colIndex1;
396404
});
397-
405+
if(sortedColumns){
406+
cells.map(selectedCells => selectedCells[1] = this.datamanager.rowViewOrder[selectedCells[1]])
407+
}
398408
return cells;
399409
}
400410

src/datamanager.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,12 +313,12 @@ export default class DataManager {
313313
this.rows.forEach((row, index) => {
314314
const viewIndex = this.rowViewOrder.indexOf(index);
315315
const cell = row[srNoColIndex];
316-
row.meta.rowIndex = viewIndex;
317-
if (Array.isArray(row)) {
318-
row.forEach(r => {
319-
r.rowIndex = viewIndex;
320-
});
321-
}
316+
// row.meta.rowIndex = viewIndex;
317+
// if (Array.isArray(row)) {
318+
// row.forEach(r => {
319+
// r.rowIndex = viewIndex;
320+
// });
321+
// }
322322
cell.content = (viewIndex + 1) + '';
323323
});
324324
}

0 commit comments

Comments
 (0)