Next
Update
Prev
Up
Down

If you set the selectionMode property to multipleCells the cell selection mode will be Multiple Cells. You can navigate the cells with the up, down, left and right keys and with the mouse click. Try to select multiple rows using Shift or Control key.

...
<DataGrid id="dg1" selectionMode="multipleCells" >
...


function selectedUp() {
  var sArr = inputForm.selectedCells.value.split(",");
  for (var j = 0 ; j < sArr.length ; j++ ) {
    var cArr = sArr[j].split(":");
    if ( cArr[0] < 1 ) {
      alert("You selected the first row.");
      return
    }	
  }
  var rArr = new Array();
  inputForm.selectedCells.value = "";
  for (var i = 0; i < sArr.length; i++) {
    var cArr = sArr[i].split(":");
    cArr[0] = cArr[0] - 1;
    rArr[i] = {rowIndex:cArr[0],columnIndex:cArr[1]};
    if (inputForm.selectedCells.value.length > 0)
      inputForm.selectedCells.value += ",";
      inputForm.selectedCells.value += cArr[0] + ":" + cArr[1];
  }
  
  dataGrid.setSelectedCells(rArr);
}

function selectedDown() {
  var sArr = inputForm.selectedCells.value.split(",");
  for (var j = 0 ; j < sArr.length ; j++ ) {
    var cArr = sArr[j].split(":");
    if ( cArr[0] >= collection.getLength() -1 ) {
      alert("You selected the last row.");
      return
    }	
  }
  var rArr = new Array();
  inputForm.selectedCells.value = "";
  for (var i = 0; i < sArr.length; i++) {
    var cArr = sArr[i].split(":");
    cArr[0] = Number(cArr[0]) + 1;
    rArr[i] = {rowIndex:cArr[0],columnIndex:cArr[1]};
    if (inputForm.selectedCells.value.length > 0)
    inputForm.selectedCells.value += ",";
    inputForm.selectedCells.value += cArr[0] + ":" + cArr[1];
  }
  
  dataGrid.setSelectedCells(rArr);
}

© 2017 KoolChart. All rights reserved.