将焦点设置到jqgrid中选择行上的可编辑输入字段 [英] Set the focus to the editable input field on select row in jqgrid
本文介绍了将焦点设置到jqgrid中选择行上的可编辑输入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的网格中,我正在使用自定义格式程序来编辑其列字段值之一.
In my grid I'm using custom formatter to edit one of its column field values.
我要在选择网格的行时将焦点设置到该可编辑字段.
I want set the focus to that editable field on selecting the row of the grid.
请帮助我...
这是我的网格
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 formatField(cellvalue, options, rowObject){
jQuery("myGrid").jqGrid('setColProp','formattedvalue',
{editable: true,
edittype:"custom",
editoptions: {
custom_element: function(value, options) {
var elemStr = '<div><input type="text" id="'+ options.id +'_id" tabindex="2" maxlength="10" size="10" value="' + value + '" /> </div>';
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();
},
未经测试,但应该可以工作
Not tested but should work
这篇关于将焦点设置到jqgrid中选择行上的可编辑输入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文