1

私のグリッドでは、カスタムフォーマッターを使用して列フィールド値の1つを編集しています。

グリッドの行を選択するときに、その編集可能なフィールドにフォーカスを設定したいと思います。

これについて私を助けてください...

これは私のグリッドです

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;}
4

1 に答える 1

0

使用できます

更新しました:

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

  },

テストされていませんが、動作するはずです

于 2013-02-12T05:32:36.683 に答える