0

我正在创建一个数据类型为 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');

但在这两种情况下,我总是会出错。

有什么解决办法吗?

4

2 回答 2

2

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

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

如果您getLocalRow在没有参数的情况下调用,则会getLocalRow看到rowid并且undefined无法返回相应行的数据。在getLocalRow退货的情况下false

于 2012-10-25T08:47:58.463 回答
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_"。

我用错了吗?

丹尼斯

于 2015-11-02T13:25:46.987 回答