2012-10-25 98 views
0

我正在创建一个数据类型为local的JQgrid,我想使用getLocalRow或getCell从编辑行中获取行值,但我总是得到false。 这是我网格的定义:jqGrid getLocalRow返回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'); 

但在这两种情况下,我总是错误的。

任何解决方案?

回答

2

方法getLocalRow有一个参数:rowid。所以getLocalRow的正确用法是

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

如果调用getLocalRow没有getLocalRow看到rowidundefined,不能回报你对相应行的数据参数。在getLocalRow返回false的情况下。

+0

对不起,但它不是解决方案。如果我使用: var localRowData = $(“#rowed5”)。jqGrid('getLocalRow',1); 我得到了同样的结果:false – Rafael

+0

@Rafael:这意味着'1'不是来自jqGrid的id。你应该把代码放在清楚的地方**你在哪里使用'getLocalRow'。此外,一些简单的测试数据('mydata')的帖子也可能有帮助。直到现在您发布了长代码,但它不包含任何'getLocalRow'调用,这是您的主要问题。 – Oleg

0

我有同样的问题,只是创建了一个fiddle。你可以通过点击一行来改变一些值。问题在于“getLocalRow”总是返回false,因为找不到rowid。我看有点到代码和jquery.jqGrid.src.js有行:

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

它被称为与ROWID =“a_jqg2”例如在this.p.idPrefix是“A_” 。

我用错了吗?

Dennis