jqGrid getLocalRow返回false

时间:2012-10-25 08:33:45

标签: jqgrid

我正在使用数据类型local创建一个JQgrid,我希望使用getLocalRow或getCell从编辑行获取行值,但我总是得到错误。 这是我的网格定义:

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 个答案:

答案 0 :(得分:2)

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

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

如果您在没有参数的情况下致电getLocalRowgetLocalRow会将rowid视为undefined,并且无法返回相应行的数据。如果getLocalRow返回false

答案 1 :(得分: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 _"。

我使用它错了吗?

丹尼斯