擴充datagrid的一個方法keyCtr
$🎜>程式碼如下:
$.extend($. fn.datagrid.methods, {
keyCtr : function (jq) {
return jq.each(function () {
var grid = $(this);
gridPanel.datagrid('getel' ).panel('panel').attr('tabindex', 1).bind('keydown', function (e) {
switch (e.keyCode) {
case 38: // 上
var selected = grid.datagrid('getSelected');
if (selected) {
var index = grid.datagrid('getRowIndex', selected);
grid.datagrid('selectRow', indexselectRow', indexselectRow', indexselectRow', indexselectRow', indexselectRow', - 1);
} else {
var rows = grid.datagrid('getRows');
grid.datagrid('selectRow', rows.length - 1);
情況40: / / 延續
var selected = grid.datagrid('getSelected');
if (selected) {
var index = grid.datagrid('getRowIndex', selected)
grid.datagrid('getRowIndex', selected)
grid.datagrid( 'selectRow ', 索引1);
} else {
grid.datagrid('selectRow', 0);
break; 🎜>});
});
}
} );