jqGrid - Select 内联编辑时选定单元格的文本

jqGrid - Select selected cell's text while inline editing

第 1 部分 在我的网格中,我有一些可编辑的列,我想对其进行内联编辑。但是,当我 select 任何特定单元格并且如果该单元格 (editable: true) 可以进行内联编辑时,它应该 select 要编辑的文本。

例如,如果这是默认网格: 然后 selecting 数量中的任何单元格,结果应该是这样的:

当我们在 jqGrid 中单击一个单元格来编辑该行时,当前的实现不会像这样突出显示 selected 文本。有什么办法可以实现吗?

第 2 部分 根据 Oleg 的建议迁移到

网格代码: jsFiddle

注意:我的真实应用数据类型是JSON

我不确定所有版本的旧网络浏览器,但是您可以将onSelectRow的代码修改为以下内容

onSelectRow: function (id) {
    var $self = $(this);
    if (id && id !== lastsel2) {
        $self.jqGrid('restoreRow', lastsel2);
        $self.jqGrid('editRow', id, {
            keys: true,
            focusField: 'Quantity',
            oneditfunc: function (rowid, options) {
                $control = $("#" + rowid + "_Quantity");
                if ($control.length > 0) {
                    $control[0].select();
                }
            },
            aftersavefunc: reload
        });
        lastsel2 = id;
    }
}

请参阅 http://jsfiddle.net/OlegKi/HJema/163/. It uses focusField: 'Quantity' option to set the focus on the 'Quantity' column. It uses select() 方法 select <input> 字段的文本。

你的问题的第二部分(关于 bindKeys)在我看来是一个单独的问题。方法 bindKeys 允许实现自定义回调 onLeftKeyonRightKey。我不太清楚你更喜欢用哪个。