如何在内联编辑jqgrid中将焦点设置在onSelectRow中的特定单元格上?
我尝试了以下答案:
1.需要 jqGrid 内联编辑才能将焦点转到单击的单元格
2.如何将焦点设置到单击以在 jqgrid 中开始内联编辑的
单元格
3.如何在 jqGrid 上编辑选定的单元格
4.设置jqgrid中选择行上可编辑输入字段的焦点
但这些都不起作用!
所以现在我不需要找到用户单击的单元格,但我需要光标准确地位于每一行的“lg_description”列中。我想问题出在 e 参数上,我认为当我将其设置为“lg_description”列时,我只需要在某处附加“lg_description”而不是 e 参数。
编辑:
这是我的代码:
onSelectRow: function(id, status, e){
var grid = $(this);
if(id && id!==lastSel){
grid.restoreRow(lastSel);
lastSel=id;
//cursor focus
//first attemp: $("#lg_description").focus();
//second attemp: $("input, select",e.target).focus();
//third attemp: document.getElementById("lg_description").focus();
//fourth attemp:
/*var setFocusToCell = function(e) {
if(!e || !e.target) return;
var $td = $(e.target).closest("td"), $tr = $td.closest("tr.jqgrow"), ci, ri, rows = this.rows;
if ($td.length === 0 || $tr.length === 0 || !rows) return;
ci = $.jgrid.getCellIndex($td[0]);
ri = $tr[0].rowIndex;
$(rows[ri].cells[ci]).find("input,select").focus();
}
setFocusToCell(e);*/
}
grid.editRow(id, true,"","","","",aftersavefunc);
//fifth attemp: grid.editRow(id, true,function() {$("#lg_description").focus();},"","","",aftersavefunc);
},
我尝试了 5 种不同的尝试,其中第 5 种替代了上面的代码