From b3e3b9e12d120185ce78da61e24df7c55f63c15d Mon Sep 17 00:00:00 2001 From: thp13123 Date: Mon, 3 Feb 2014 18:37:04 +0100 Subject: [PATCH] make CellSelection work with tree mode Another patch for issue #761 Inspired of 87fe012e3e8b808b38fba194819819588e76ca09 --- CellSelection.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CellSelection.js b/CellSelection.js index 12c2fc761..7346aaed1 100644 --- a/CellSelection.js +++ b/CellSelection.js @@ -102,7 +102,8 @@ return declare(Selection, { // find if it is earlier or later in the DOM var traverser = (toElement && (toElement.compareDocumentPosition ? toElement.compareDocumentPosition(fromElement) == 2 : - toElement.sourceIndex > fromElement.sourceIndex)) ? "nextSibling" : "previousSibling"; + toElement.sourceIndex > fromElement.sourceIndex)) ? "down" : "up"; + // now we determine which columns are in the range var idFrom = cell.column.id, idTo = toCell.column.id, started, columnIds = []; for(id in this.columns){ @@ -120,19 +121,19 @@ return declare(Selection, { } } // now we iterate over rows - var row = cell.row, nextNode = row.element; + var row = cell.row; toElement = toCell.row.element; do{ // looping through each row.. // and now loop through each column to be selected for(i = 0; i < columnIds.length; i++){ - cell = this.cell(nextNode, columnIds[i]); + cell = this.cell(row, columnIds[i]); this._select(cell, null, value); } - if(nextNode == toElement){ + if(row.element == toElement){ break; } - }while((nextNode = cell.row.element[traverser])); + }while(row = this[traverser](row)); } } },