扩展datagrid の 1 つの方法keyCtr
$.extend($. fn.datagrid.methods, {
keyCtr : function (jq) {
return jq.each(function () {
var Grid = $(this);
grid.datagrid('getPanel' ).panel('panel').attr('tabindex', 1).bind('keydown', function (e) {
switch (e.keyCode) {
case 38: // up
var selected = Grid.datagrid('getSelected');
if (selected) {
varindex = Grid.datagrid('selectRow', selected); - 1);
} else {
var rows = Grid.datagrid('getRows');
grid.datagrid('selectRow', rows.length - 1); Break;
case 40: // down
var selected = Grid.datagrid('getSelected');
if (selected) {
varindex = Grid.datagrid('getRowIndex', selected) ;
grid.datagrid('selectRow', インデックス 1);
grid.datagrid('selectRow', 0);
}
});
});
}
});