将焦点设置为jqgrid中选定行的可编辑输入字段

在我的网格中,我使用自定义格式化程序来编辑其中一个列字段值。

我想在选择网格行时将焦点设置到该可编辑字段。

请帮帮我…

这是我的网格

jQuery("#myGrid").jqGrid({ datatype: "local", colNames:['','','',''], colModel:[{name:'id',index:'id', width:50, hidden:true}, {name:'activname',index:'activname', width:100, title: false}, {name:'formattedvalue',index:'formattedvalue', width:200, formatter:formatField}, {name:'value',index:'value', hidden:true}], height: window.innerHeight - 318, onSelectRow: function(id,stat,e) { // here I want to set the focus to the editable field }}); 

这是格式化程序function

 function formatField(cellvalue, options, rowObject){ jQuery("myGrid").jqGrid('setColProp','formattedvalue', {editable: true, edittype:"custom", editoptions: { custom_element: function(value, options) { var elemStr = '
'; var $custElem = jQuery(elemStr); $custElem.find("input").bind("keydown",function(e) { return dynamicFieldKeyPressed(e, this, rowObject); }); return $custElem[0]; }, custom_value: function(elem, operation, value){ return jQuery(elem).find("input").val(); } } }); return cellvalue;}

您可以使用

更新:

  onSelectRow: function(id,stat,e){ if(id && id!==lastSel){ jQuery('#myGrid').restoreRow(lastSel); lastSel=id; } jQuery('#myGrid').editRow(id, true); $("#"+id+"_formattedvalue").focus(); }, 

没有测试但应该工作