Jquery jqGrid-在Firefox中不关注点击的电子编辑字段

Jquery jqGrid-在Firefox中不关注点击的电子编辑字段,jquery,jqgrid,Jquery,Jqgrid,我正在使用jqGrid和onsetrow函数编辑网格中的一行。当我在行中选择我所选的单元格时,它将获得焦点,而在Firefox上,当我尝试单击同一行中的另一个单元格时,它将不会获得焦点。我要么需要用tab键点击它,要么选择我们的行并返回到它 它在铬合金中工作良好 代码如下: gridElement.jqGrid({ url: $.url("/MyURL"), postData: { ID: function () { return $('#IDVAL').

我正在使用jqGrid和onsetrow函数编辑网格中的一行。当我在行中选择我所选的单元格时,它将获得焦点,而在Firefox上,当我尝试单击同一行中的另一个单元格时,它将不会获得焦点。我要么需要用tab键点击它,要么选择我们的行并返回到它

它在铬合金中工作良好

代码如下:

    gridElement.jqGrid({
    url: $.url("/MyURL"),
    postData: {
        ID: function () { return $('#IDVAL').val(); }
    },
    datatype: "json",
    mtype: "POST",
    colNames: ['Name', 'Numbers', 'Options', 'TextBox', 'Hide'],
    colModel: [
       { name: 'Name', index: 'Name', width: 200, hidden: false },

       { name: 'Numbers', index: 'Type', width: 120, editable: true, edittype: "select", editoptions: { value: { 0: 'None', 1: 'One', 2: 'Two' }, dataInit: function (elem) { $(elem).width(85); } } },
       { name: 'Options', index: 'Summary', width: 120, editable: true, edittype: "select", editoptions: { value: { 0: 'None', 1: 'Option 1', 2: "Option 2" }, dataInit: function (elem) { $(elem).width(85); } } },
       { name: 'TextBox', index: 'TextBox', width: 300, edittype: "text", editable: true, editoptions: { size: "50", maxlength: "100"} },
       { name: 'Hide', index: 'Hide', width: 80, editable: true, edittype: "checkbox", editoptions: { value: "true:false"} }
          ],
    rowNum: 50,
    width: 800,
    height: "auto",
    loadtext: "Please wait...",
    viewrecords: true,
    hidegrid: false,
    onSelectRow: function (id) {
        if (id && id !== lastselref) {
            gridElement.saveRow(lastselref, false, 'clientArray', '');
            gridElement.jqGrid('restoreRow', lastselref);
            gridElement.jqGrid('editRow', id, true);

            lastselref = id;

        }
    },
    forceFit: true
});

代码中有一些奇怪的部分,我建议您进行更改,但在此之前,我想指出您关注的问题

问题是jqGrid首先搜索行中第一个可编辑单元格的索引(请参见),然后仅将其设置为单元格的
元素,跳过您拥有的
(请参见):

setTimeout(function(){$('td:eq(“+focus+”)输入),ind.focus();},0);
例如,可以修复以下问题

setTimeout(function(){$(“td:eq(“+focus+”)):输入:可见,ind.focus();},0);
其中伪选择器和将像jqGrid代码的许多其他地方一样使用

可用于重现您的问题(只需单击一行并尝试使用箭头按钮查看焦点未设置在编辑行中的select元素上),并用于jqGrid

我报告了错误和我的建议

代码中的其他一些小注释:

  • 对于
    colModel
    name:'Numbers',index:'Type'
    name:'Options',index:'Summary'
    )的
    name
    index:'Summary'属性,我不建议使用不同的值。如果您确实需要在服务器端使用
    索引
    other作为输入数据中的属性名称进行排序,那么最好使用
    jsonmap
    而不是名称。例如
    name:'Type',index:'Type',jsonmap:'Numbers'
    。一般来说,我建议不要使用
    index
    属性。在这种情况下,将使用
    name
    属性的值:
    name:'Type',jsonmap:'Numbers'
  • 你应该考虑使用,你没有那么多的数据行。
  • 您应该始终使用
    gridview:true
    选项来提高网格的性能(请参阅)
  • 我建议您使用
    autoencode:true
    选项,强制jqGrid将输入数据解释为文本,而不是HTML片段
更新:我发布的内容已经合并到jqGrid的主代码中。因此,上述更改(
“td:eq(“+focus+”)input“
”到
“td:eq(“+focus+”):input:visible”
)将出现在jqGrid的下一版本中