0
votes

I'm creating a JQgrid with datatype local and I want to get row values from editing row using getLocalRow or getCell but I always get false. This is my grid definition:

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);

    }
});

The onSelectRow function is:

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();
    }
}

I try to get row info using:

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

But in both case I always get false.

Any solution?

2

2 Answers

2
votes

The method getLocalRow has one parameter: rowid. So the correct usage of getLocalRow is

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

If you call getLocalRow without the parameter the getLocalRow sees rowid as undefined and can't return you the data for the corresponding row. In the case the getLocalRow returns false.

0
votes

I've got the same issue and just created a fiddle. You can change some some values by clicking on a row. The problem is that "getLocalRow" always returns false because the rowid is not found. I look a little bit into the code and in jquery.jqGrid.src.js there is the row:

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

it is called with rowid="a_jqg2" for example where this.p.idPrefix is "a_".

Am I using it wrong?

Dennis