Bind 'keydown' event for datagrid outer panel:
$('#test').datagrid('getPanel').panel('panel').attr('tabindex',1).bind('keydown',function(e){
switch(e.keyCode){
case 38: // up
var selected = $('#test').datagrid('getSelected');
if (selected){
var index = $('#test').datagrid('getRowIndex', selected);
$('#test').datagrid('selectRow', index-1);
} else {
$('#test').datagrid('selectRow', 0);
}
break;
case 40: // down
var selected = $('#test').datagrid('getSelected');
if (selected){
var index = $('#test').datagrid('getRowIndex', selected);
$('#test').datagrid('selectRow', index+1);
} else {
$('#test').datagrid('selectRow', 0);
}
break;
}
});