2016-11-04 16 views
0

ダブルクリックすることなく選択した内容をセルを選択する場合を除いて、以下のjqGridが必要に応じて動作します。クラスの属性を 'reading'列に追加しました。フォーカスでセルの内容を強調表示する方法

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%> 

<div class="miscdisplayheader"> 
    <img title="Close" class="modified20 ifetestestdetailsFormClose_cellEdit floatright" src="/QMSWebApp/Images/close[1].jpg"> 
</div> 

<table id="ifetestdetailslist"></table> 
<div id="ifetestdetailspager"></div> 
$(document).ready(function() { 
    var lastsel; 
    var selID = ""; 

    $("#ifetestdetailslist").jqGrid({ 
     url: '/QMSWebApp/IFETestingControllerServlet?lifecycle=loadifetestdetailsDataModel', 
     editurl: '/QMSWebApp/IFETestingControllerServlet?lifecycle=editifetestdetailsdatamodel', 
     datatype: "json", 
     height: "auto", 
     colNames: ['Index', 'Test Index', 'Reference', 'Value'], 
     colModel: [{ 
      name: 'id', 
      index: 'id', 
      width: 100, 
      hidden: true, 
      editable: true, 
      editrules: { 
       edithidden: true 
      }, 
      formoptions: { 
       rowpos: 1, 
       colpos: 1, 
       label: "Index:" 
      } 
     }, { 
      name: 'testindex', 
      index: 'testindex', 
      width: 100, 
      hidden: true, 
      editable: true, 
      editrules: { 
       edithidden: true 
      }, 
      formoptions: { 
       rowpos: 2, 
       colpos: 1, 
       label: "Test Index:" 
      } 
     }, { 
      name: 'refno', 
      index: 'refno', 
      width: 300, 
      hidden: false, 
      editable: false, 
      editoptions: { 
       readonly: 'readonly' 
      }, 
      editrules: { 
       edithidden: true 
      }, 
      formoptions: { 
       rowpos: 3, 
       colpos: 1, 
       label: "Reference:" 
      } 
     }, { 
      name: 'reading', 
      index: 'reading', 
      width: 300, 
      hidden: false, 
      editable: true, 
      editrules: { 
       edithidden: true 
      }, 
      formoptions: { 
       rowpos: 4, 
       colpos: 1, 
       label: "Value:" 
      }, 
      editrules: { 
       custom: true, 
       custom_func: myValidate1 
      }, 
      classes: 'highlightAll' 
     }, ], 
     rowNum: 10, 
     rowList: [10, 20, 30], 
     loadonce: true, 
     pager: '#ifetestdetailspager', 
     'cellEdit': true, // TRUE = turns on celledit for the grid. 
     'cellsubmit': 'remote', 
     cellurl: '/QMSWebApp/IFETestingControllerServlet?lifecycle=editifetestdetailsdatamodel', 
     viewrecords: true, 
     gridview: true, 
     loadComplete: lComplete, 
     reloadAfterSubmit: true, 
     caption: "Test Details" 
    }); 

    function lComplete(data) { 
     $('.highlightAll').on("focus", function() { 
      $(this).select(); 
     }); 
     hideProgressDisplay(); 
    }; 

    function myValidate1(value, colname) { 
     var readingV = parseFloat(value); 
     if (readingV <= 0 || readingV >= 30) { 
      return [false, " Value must be > 0 and < 30."]; 
     } else { 
      return [true, ""]; 
     } 
    } 

    $('.ifetestestdetailsFormClose_cellEdit').on("click", function() { 
     //$("#ifetestingdatalist").jqGrid('setGridParam',{ datatype: 'json' }).trigger('reloadGrid')   
     $('.miscdisplay').hide("slide", { 
      direction: "right" 
     }, 1000); 
    }); 
}); 

アップデート: 私もこれを試してみましたが、まだ動作しません。コンテンツのように、編集の準備ができていません。手動で選択またはダブルクリックする必要があります。

colNames:['Index','Test Index','Reference','Value'], 
    colModel:[ 
     {name:'id', index:'id', width:100, hidden: true, editable: true, editrules:{edithidden:true}, formoptions:{rowpos:1, colpos:1,label:"Index:"}}, 
     {name:'testindex', index:'testindex', width:100, hidden: true, editable: true, editrules:{edithidden:true}, formoptions:{rowpos:2, colpos:1,label:"Test Index:"}}, 
     {name:'refno', index:'refno', width:300, hidden: false, editable: false, editoptions:{ readonly:'readonly'}, editrules:{edithidden:true}, formoptions:{rowpos:3, colpos:1,label:"Reference:"}}, 
     {name:'reading', index:'reading', width:300, hidden: false, editable: true, editrules:{edithidden:true}, formoptions:{rowpos:4, colpos:1,label:"Reading:"}, editrules: {custom: true, custom_func: myValidate1}, classes: 'highlightAll'}, 
     ], 
     rowNum:10, 
     rowList:[10,20,30], 
     loadonce: true, 
     pager: '#ifetestdetailspager', 
     'cellEdit': true, // TRUE = turns on celledit for the grid. 
     'cellsubmit' : 'remote', 
     cellurl: '/QMSWebApp/IFETestingControllerServlet?lifecycle=editifetestdetailsdatamodel', 
     beforeEditCell: function(rowid,cellname,value,iRow,iCol){ 
      $("#" + rowid + "_reading").select(); 

     }, 
     viewrecords: true, 
     gridview: true, 
     loadComplete: lComplete, 
     reloadAfterSubmit: true, 
     caption:"Test Details" 

    }); 

答えて

0

私は答えを考え出した:

afterEditCell: function(rowid,cellname,value,iRow,iCol){ 
      $('.edit-cell > input').select(); 
     }, 
関連する問題