Jqgrid键盘导航问题

时间:2014-02-25 08:35:29

标签: javascript jquery jquery-ui jqgrid

以下是jsfiddle的链接。如果我们删除

jQuery("#grid").jqGrid('sortableRows');

我们可以使用键盘导航键滚动行。但我也想要畅通无阻的行。所以,当我添加这个时,我能够对行进行排序,但键控导航不起作用

Javascript代码

jQuery("#grid").jqGrid({
    datatype: "local",
    sortable: true,
    height: 250,
       colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
       colModel:[
           {name:'id',index:'id', width:60, sorttype:"int"},
           {name:'invdate',index:'invdate', width:90, sorttype:"date"},
           {name:'name',index:'name', width:100},
           {name:'amount',index:'amount', width:80, align:"right",sorttype:"float"},
           {name:'tax',index:'tax', width:80, align:"right",sorttype:"float"},        
           {name:'total',index:'total', width:80,align:"right",sorttype:"float"},        
           {name:'note',index:'note', width:150, sortable:false}        
       ],
       multiselect: false,
       caption: "Manipulating Array Data"
});
var mydata = [
        {id:"1",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
        {id:"2",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
        {id:"3",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
        {id:"4",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
        {id:"5",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
        {id:"6",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
        {id:"7",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
        {id:"8",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
        {id:"9",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}
        ];
for(var i=0;i<=mydata.length;i++)

    jQuery("#grid").jqGrid('addRowData',i+1,mydata[i]);


jQuery("#grid").jqGrid('bindKeys');
jQuery("#grid").jqGrid('sortableRows');

http://jsfiddle.net/uTqD5/118/#&togetherjs=ptdwchkcKu

此致

麦克莱恩·莫里斯·平托

2 个答案:

答案 0 :(得分:0)

可以在您的情况下使用绑定键方法。你试过吗?

http://www.trirand.com/jqgridwiki/doku.php?id=wiki%3amethods

根据文件:

  

调用方法时,可以选择一行   使用向上和向下键 - 即我们用键滚动网格数据。它是   选择行时可以调用其他事件和a   按下键,如输入,空格,左或右。对这些事件a   选定的行ID将作为参数传递。

答案 1 :(得分:0)

不知道你是否解决了这个问题,但我遇到了同样的问题,解决方法是在创建网格时添加它:

onSelectRow: function (rowid) {
            $('#' + rowid).focus();
        }