如何将焦点设置到单击以开始在jqgrid中进行内联编辑的单元格 [英] How to set focus to cell which was clicked to start inline edit in jqgrid

查看:142
本文介绍了如何将焦点设置到单击以开始在jqgrid中进行内联编辑的单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在jqgrid中,双击单元格可开始内联编辑. 光标位于第一个可编辑的列. 需要第二次单击才能将光标置于被单击的单元格上.

In jqgrid inline editing is stared by double clicking in a cell. Cursor is positioned to first editable column. Second click in required to place cursor to the cell which was clicked.

如何将光标置于单击以开始内联编辑的单元格上? 在单元格编辑模式下,单击的单元格会正确接收焦点.

How to put cursor to the cell which was clicked to start inline edit? In cell edit mode clicked cell receives focus properly.

function beginInlineEdit(rowID, afterSave) {
    var grid2 = $("#grid");
    if (rowID && rowID !== lastSelectedRow) {
        var scrollPosition = $("#grid").closest(".ui-jqgrid-bdiv").scrollLeft();
        cancelEditing($("#grid"));
        lastSelectedRow = rowID;
        setTimeout(function () {
            grid2.closest(".ui-jqgrid-bdiv").scrollLeft(scrollPosition);
        }, 100);
    }
    $("tr#" + lastSelectedRow + " div.ui-inline-edit, " + "tr#" + lastSelectedRow + " div.ui-inline-del").hide();
    $("tr#" + lastSelectedRow + " div.ui-inline-save, " + "tr#" + lastSelectedRow + " div.ui-inline-cancel").show();

    $("#grid").jqGrid('editRow', lastSelectedRow, true, null, null, null,
                 { _dokdata: FormData },
                 afterSave,
                 errorfunc,
                 function () {
                     cancelEditing($("#grid"));
                     setFocusToGrid();
                 }
             );
}

更新1

我在IE9中尝试了Oleg演示.问题:

I tried Oleg demo in IE9. Issues:

  1. 双击复选框列仍将焦点放在第一列.

  1. double-clicking in checkbox column still puts focus to first column.

我减小了浏览窗口的宽度并向右滚动.单击最严格的列会导致奇怪的快速闪烁:网格滚动到最左侧的位置,然后滚动到最右侧.

I decreased browse window width and scrolled right. Clicking in righmost column causes strange rapid flashing: grid scrolls to leftmost position and after that back to right position.

如何解决这些问题?

推荐答案

查看来自答案的演示 一个>.该演示完全可以满足您的需求,或者您可以根据自己的目的修改该演示.

Look at the demo from the answer. Either the demo do exactly what you need or you can modify the demo to your purposes.

已更新:1)您是否尝试过我的原始演示,还是尝试在您的代码中使用了所描述的想法?在我的环境中(在不同的计算机上)该演示将重点放在了单击的单元格.在IE9(本机甚至是兼容模式下),IE8,Google Chrome 13,Safari 5.1,Opera 11.50,Firefox 3.6.20和Nightly 9.0a1(Firefox的下一个版本)中,它都能正常工作.

UPDATED: 1) Do you tried my original demo or you tried to use the described idea in your code? In my environment (on different computers) the demo put the focus in the clicked cell. It works correct in IE9 (in native and even in the compatibility mode), IE8, Google Chrome 13, Safari 5.1, Opera 11.50, Firefox 3.6.20 and Nightly 9.0a1 (next version of Firefox).

2)正确的行为是,首先在第一个编辑位置滚动网格,然后再滚动到单击的单元格.默认情况下,jqGrid内联编辑将焦点放在第一个编辑单元上,然后在

2) The scrolling grid at the first editing position first and then to the clicked cell is the correct behavior. Per default jqGrid inline editing set the focus on the first editing cell and then, inside of oneditfunc callback function of editRow, we change the focus to clicked cell.

这篇关于如何将焦点设置到单击以开始在jqgrid中进行内联编辑的单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆