2012-10-25 2 views
0

데이터 유형이 local 인 JQgrid를 만들고 getLocalRow 또는 getCell을 사용하여 행 편집에서 행 값을 가져 오려고하지만 항상 false가 표시됩니다.jqGrid getLocalRow return false

jQuery("#rowed5").jqGrid({ 
    datatype: 'local', 
    data: mydata, 

    loadtext:"Cargando...", 
    height: altura*0.4, 
    width: anchoDefecto*0.9, 
    colNames:['Cuenta', 
       'Subcuenta', 
       'Importe', 
       'Signo', 
       'Clave', 
       'Documento', 
       'Doc. Referencia', 
       'Ampliación', 
       'Extensión'], 
    colModel:[ 
      {name:'intIdfCuenta',index:'intIdfCuenta', width:200, sorttype:"int", editable:true,editrules:{required:true}, edittype:'custom', 
       editoptions:{custom_element: myelemcuentas, custom_value:myvaluecuentas} }, 
      {name:'intIdfSubcuenta',index:'intIdfSubcuenta', width:200,editable: true,editrules:{required:true}, edittype:'custom', 
        editoptions:{custom_element: myelemsubcuentas, custom_value:myvaluesubcuentas}}, 
      {name:'floatImporte',index:'floatImporte', width:200,editable: true,editrules:{required:true}, edittype:'text'}, 
      {name:'strSigno',index:'strSigno', width:200,editable: true, edittype:'custom',editrules:{required:true}, 
       editoptions:{custom_element: myelemsigno, custom_value:myvaluesigno} }, 
      {name:'strIdfClave',index:'strIdfClave', width:200,editable: true,editrules:{required:true}, edittype:'custom', 
        editoptions:{custom_element: myelemclave, custom_value:myvalueclave} }, 
      {name:'strDocumento',index:'strDocumento', width:200,editable: true,editrules:{required:true},edittype:'text'}, 
      {name:'strDocumentoReferencia',index:'strDocumentoReferencia', width:200,editable: true,edittype:'text'}, 
      {name:'strAmpliacion',index:'strAmpliacion', width:200,editable: true,edittype:'text',editoptions: { 
      dataInit: function (elem) { $(elem).focus(function() { this.select(); }) }, 
      dataEvents: [ 
       { 
        type: 'keydown', 
        fn: function (e) { 
         var key = e.charCode || e.keyCode; 
         if (key == 9) 
         { 
          procesarTabulacionAmpliacion(); 
         } 
        } 
       } 
      ] 
      } 
      }, 
      {name:'strIdfTipoExtension',index:'strIdfTipoExtension', width:200,editable:true,edittype:'custom', 
       editoptions:{custom_element: myelemextension, custom_value:myvalueextension} } 
      ], 
    cellsubmit: "clientArray", 
    pager:"#pager", 
    onSelectRow: function(id){   
     selectNextRow(id); 

    } 
}); 

onSelectRow 기능은 다음과 같습니다 :

function selectNextRow(id){  
    if (lastsel!=null && id!==lastsel && !myRowIsValid(lastsel)) { 
     if(lastsel!=null && id!==lastsel){ 
      jQuery('#rowed5').jqGrid('setSelection', lastsel); 
     } 
     return false; 
    }else if(id && id!==lastsel){  
     newline = '0';   
     jQuery("#rowed5").saveRow(lastsel, false, 'clientArray'); 
     jQuery("#rowed5").editRow(id, false); 

     lastsel=id; 
     actsel = id; 
     // ponemos foco 
     $(getId("intIdfCuenta",actsel,true)).focus(); 
    } 
} 

내가 사용 정보를 행 얻으려고 : 이 내 그리드의 정의입니다

  var floatImporte = $("#rowed5").jqGrid('getCell', 'floatImporte'); 
      var localRowData = $("#rowed5").jqGrid('getLocalRow'); 

그러나 두 경우에 나는 항상 false를 얻는다.

모든 솔루션?

답변

2

getLocalRow에는 rowid 매개 변수가 있습니다. 당신이 getLocalRowundefinedrowid보고 해당 행에 대해 당신에게 데이터를 반환 할 수없는 매개 변수없이 getLocalRow를 호출 할 경우 그래서 getLocalRow의 올바른 사용은

var localRowData = $("#rowed5").jqGrid('getLocalRow', id); 

입니다. 이 경우 getLocalRowfalse을 반환합니다.

+0

죄송하지만 해결책은 아닙니다. 내가 사용하는 경우 : var localRowData = $ ("# rowed5"). jqGrid ('getLocalRow', 1); 동일한 결과를 얻습니다. false – Rafael

+0

@Rafael : '1'은 jqGrid의 ID가 아닙니다. ** getLocalRow'를 사용하여 어디에서 ** 어떤 문맥을 사용하는지 명확한 곳에 코드를 게시해야합니다. 또한 간단한 테스트 데이터 ('mydata')의 게시물도 도움이 될 수 있습니다. 지금까지는 긴 코드를 게시했지만 주요 문제점 인'getLocalRow' 호출을 포함하지 않습니다. – Oleg

0

동일한 문제가 있으며 방금 fiddle을 만들었습니다. 행을 클릭하여 일부 값을 변경할 수 있습니다. 문제는 "getLocalRow"는 rowid가 없기 때문에 항상 false를 반환한다는 것입니다. 나는 코드에 조금보고 jquery.jqGrid.src.js에 행이 :

ind = this.p._index[stripPref(this.p.idPrefix, rowid)]; 

가 ROWID = "a_jqg2"로 호출 예를 들어 this.p.idPrefix는 "A_가" .

잘못 사용하고 있습니까?

데니스

관련 문제