问题描述
第1部分:在我的网格中,我有一些可编辑的列,我想在其中进行内联编辑。但是,当我选择任何特定单元格并且该单元格上的内联编辑可用时( editable:true
),它应该选择要编辑的文本。
Part 1) In my grid, I have some editable columns which I would like to do inline editing to. However when I select any particular cell and if the inline editing is available on that cell (editable: true
), it should select the text to be edited.
例如,如果这是默认网格:
然后在选择Quantity中的任何单元格时,结果应该是是这样的:
For example if this is the default grid:then upon selecting any cell in Quantity, the result should be something like this:
当我们点击一个单元格来编辑jqGrid中的那一行时,当前实现不会突出显示这样的选定文本。有没有办法实现这个目标?
When we click on a cell to edit that row in jqGrid, current implementation does not highlight the selected text like this. Is there any way to achieve this?
第2部分)迁移到根据Oleg的建议
Part 2) Migrated to this question as per Oleg's suggestion
网格代码:
注意:我的真实应用程序数据类型是 JSON
Note: My real application datatype is JSON
推荐答案
我不确定旧版网页浏览器的所有版本,但您可以将 onSelectRow
的代码修改为以下
I'm not sure about all versions of old web browsers, but you can modify the code of onSelectRow
to the following
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;
}
}
参见。它使用 focusField:'Quantity'
选项将焦点设置在'Quantity'
列上。它使用方法选择<的文本。输入>
字段。
see http://jsfiddle.net/OlegKi/HJema/163/. It uses focusField: 'Quantity'
option to set the focus on the 'Quantity'
column. It uses select() method to select the text of <input>
field.
问题的第二部分(关于 bindKeys
)似乎给我一个单独的问题。方法 bindKeys
允许实现自定义回调 onLeftKey
, onRightKey
。哪一个你想要更好地使用对我来说并不完全清楚。
The second part of your question (about bindKeys
) seems to me a separate question. The method bindKeys
allows to implement custom callbacks onLeftKey
, onRightKey
. Which one you would like better to use is not full clear for me.
这篇关于jqGrid - 在内联编辑时选择单元格的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!