JqGrid中自动完成上下键导航

JqGrid中自动完成上下键导航,jqgrid,Jqgrid,我用修改过的cellEdit(完全上下左右单元格导航)获得了JqGrid 以下是jqgrid.src的一些内容: if (e.keyCode === 37) { if(!$t.grid.hDiv.loading ) { {$($t).jqGrid("prevCell",iRow,iCol);} //left } else {

我用修改过的cellEdit(完全上下左右单元格导航)获得了JqGrid

以下是jqgrid.src的一些内容:

                if (e.keyCode === 37)  {
                    if(!$t.grid.hDiv.loading ) {
                        {$($t).jqGrid("prevCell",iRow,iCol);} //left
                    } else {
                        return false;
                    }
                }
                if (e.keyCode === 39)  {
                    if(!$t.grid.hDiv.loading ) {
                        {$($t).jqGrid("nextCell",iRow,iCol);} //right
                    } else {
                        return false;
                    }
                }
                if (e.keyCode === 38)  {
                    if(!$t.grid.hDiv.loading ) {
                        {$($t).jqGrid("prevRow",iRow,iCol);} //up
                    } else {
                        return false;
                    }
                }   
                if (e.keyCode === 40)  {
                    if(!$t.grid.hDiv.loading ) {
                        {$($t).jqGrid("nextRow",iRow,iCol);} //down

                    } else {
                        return false;
                    }
                }
及其他

    nextCell : function (iRow,iCol) {
    return this.each(function (){
        var $t = this, nCol=false, i;
        if (!$t.grid || $t.p.cellEdit !== true) {return;}
        // try to find next editable cell
        for (i=iCol+1; i<$t.p.colModel.length; i++) {
            if ($t.p.colModel[i].editable ===true && $t.p.colModel[i].hidden !== true ) {
                //alert($t.p.colModel[i-1].hidden);
                nCol = i; break;
            }
        }
        if(nCol !== false) {
            $($t).jqGrid("editCell",iRow,nCol,true);
        } else {
            if ($t.p.savedRow.length >0) {
                $($t).jqGrid("saveCell",iRow,iCol);
            }
        }
    });
},
prevCell : function (iRow,iCol) {
    return this.each(function (){
        var $t = this, nCol=false, i;
        if (!$t.grid || $t.p.cellEdit !== true) {return;}
        // try to find next editable cell
        for (i=iCol-1; i>=0; i--) {
            if ($t.p.colModel[i].editable ===true && $t.p.colModel[i].hidden !== true ) {
                nCol = i; break;
            }
        }
        if(nCol !== false) {
            $($t).jqGrid("editCell",iRow,nCol,true);
        } else {
            if ($t.p.savedRow.length >0) {
                $($t).jqGrid("saveCell",iRow,iCol);
            }
        }
    });
},
prevRow : function (iRow,iCol) {
    return this.each(function (){
        var $t = this, nCol=false, i;
        if (!$t.grid || $t.p.cellEdit !== true) {return;}
        // try to find next editable cell
        iRow--;
        iCol++;
        for (i=iCol-1; i>=0; i--) {
            if ( $t.p.colModel[i].editable ===true) {
                nCol = i; break;
            }
        }
        if(nCol !== false) {
            $($t).jqGrid("editCell",iRow,nCol,true);
        } else {
            if ($t.p.savedRow.length >0) {
                $($t).jqGrid("saveCell",iRow,iCol);
            }
        }
    });
},
nextRow : function (iRow,iCol) {
    return this.each(function (){
        var $t = this, nCol=false, i;
        if (!$t.grid || $t.p.cellEdit !== true) {return;}
        // try to find next editable cell
        iRow++;
        iCol++;
        for (i=iCol-1; i>=0; i--) {
            if ( $t.p.colModel[i].editable ===true) {
                nCol = i; break;
            }
        }
        if(nCol !== false) {
            $($t).jqGrid("editCell",iRow,nCol,true);
        } else {
            if ($t.p.savedRow.length >0) {
                $($t).jqGrid("saveCell",iRow,iCol);
            }
        }
    });
}
}


这里的问题是,我无法管理热键来工作,当我按下“向下”按钮时,它只会转到下一个单元格,而不是任何自动完成选项。

当自动完成元素可见时,您可以取消jqgrid导航。比如:

$(document).keydown(function( fn ){
      var key = fn.keyCode;
      if( $("#autocomplete") && key == 40)
           /* your autocomplete action*/
});

这并不完全是我所需要的,但它帮助我做到了

我刚刚修改了jqgrid源代码,如下所示:

if (e.keyCode === 40)  {
                    if(!$t.grid.hDiv.loading ) {
                        if ($('.ui-menu-item').length < 1) {
                        {$($t).jqGrid("nextRow",iRow,iCol);} //down
                        }
                    } else {
                        return false;
                    }
                }
if(e.keyCode==40){
如果(!$t.grid.hDiv.loading){
如果($('.ui菜单项')。长度<1){
{$($t).jqGrid(“nextRow”,iRow,iCol);}//down
}
}否则{
返回false;
}
}
其中.ui菜单项是自动完成小部件的类

很多

if (e.keyCode === 40)  {
                    if(!$t.grid.hDiv.loading ) {
                        if ($('.ui-menu-item').length < 1) {
                        {$($t).jqGrid("nextRow",iRow,iCol);} //down
                        }
                    } else {
                        return false;
                    }
                }