EasyUI Forum

General Category => General Discussion => Topic started by: bvicencio on July 03, 2012, 08:22:42 AM



Title: As I can use the up, down, left or to right in a datagrid?
Post by: bvicencio on July 03, 2012, 08:22:42 AM
As I can use the up, down, left or to right in a datagrid?

Gracias por su ayuda


Title: Re: As I can use the up, down, left or to right in a datagrid?
Post by: stworthy on July 06, 2012, 06:48:09 AM
Bind 'keydown' event for datagrid outer panel:
Code:
$('#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;
}
});


Title: Re: As I can use the up, down, left or to right in a datagrid?
Post by: bvicencio on July 09, 2012, 02:06:14 PM
Great!!... Thank you very much. It's usefull