cells method usage

Please explain why calling ‘cells’ method inside an event/function produces the expected result

myGrid.attachEvent('onRowSelect', function(id,ind){
//returns selected row id (e.g. 1001) and cell index (e.g. 3) 
  var myCell = myGrid.cells(id,ind).getValue();
  console.log(myCell);// returns selected cell value
});

Yet, when used alone and provided the same parameters manually it errors?

var myCell = myGrid.cells(1001,3).getValue();
console.log(myCell);
// returns error "Cannot read property '_childIndexes' of null
// dhtmlxGridObject.cells @ dhtmlx.js:9
// anonymous function @ griddemo.html:53

Thank you

Please disregard. I figured it out. Being asynchronous, all XML data was not available to the grid when the cells().getValue() was executed causing a null value.

I used an onXLE event to wait until the XML data was loaded before executing and it works great.

myGrid.attachEvent('onXLE', function(){
  var myCell = myGrid.cells(1001,2).getValue();
  console.log(myCell);
});