代码之家  ›  专栏  ›  技术社区  ›  Garis M Suero

向jqgrid上的editURL发送附加参数

  •  2
  • Garis M Suero  · 技术社区  · 14 年前

    我现在的问题是要发送身份证( editable: false )在编辑该行时。

    例如,我有一个带有列userid的网格( 可编辑:假 )用户名( editable: true (第一名) 可编辑的:真的 ) 可编辑的:真的 )编辑行时,网格只发送参数username、firstname和lastname。在服务器端,我需要用户ID来知道我将这些新值应用到了哪个用户。

    editURL如下所示:

    editurl : CONTEXT_PATH+'/ajax/admin/savePart.do?category=1',
    

    谢谢

    这是完整代码:

    $.jgrid.useJSON = true;
    //http://www.trirand.com/jqgridwiki/doku.php?id=wiki%3Acommon_rules
    $(document).ready(function() {
        //alert(CONTEXT_PATH);
        var lastsel;
        jQuery("#rowed3").jqGrid(
                {
                    url : CONTEXT_PATH+'/ajax/getPartesByCategory.do?catid=<s:property value="categoryId" />',
                    //url : '/autoWEB/text.html',
                    datatype: "json",
                    ajaxGridOptions: { contentType: "application/json" },
                    jsonReader : { 
                        root: "rows", 
                        page: "page", 
                        total: "total", 
                        records: "records", 
                        repeatitems: false 
                    },
                    headertitles: true,
                    colNames : [ 'ID', 'Pieza', 'Disponible'],
                    colModel : [ {
                        name : 'piezaId',
                        index : 'piezaId',
                        align : "right",
                        width : 50, 
                        editable : false,
                        required : true
                    }, {
                        name : 'descripcion',
                        index : 'descripcion',
                        width : 390,
                        editable : true,
                        required : true
                    }, {
                        name : 'disponible',
                        index : 'disponible',
                        width : 80,
                        editable : true,
                        edittype : 'select',
                        editoptions:{value:"0:No;1:Si"},
                        required : true
                    } ],
                    rowNum : 20,
                    rowList : [ 20, 40, 60, 80 ],
                    pager : '#prowed3',
                    sortname : 'piezaId',
                    postData: {piezaId : lastsel},
                    mtype:"POST",
                    viewrecords : true,
                    sortorder : "desc",
                    onSelectRow : function(id) {
                        if (id && id !== lastsel) {
                            jQuery('#rowed3').jqGrid('restoreRow', lastsel);
                            jQuery('#rowed3').jqGrid('editRow', id, true);
                            lastsel = id;
                        }
                    },
                    editurl : CONTEXT_PATH+'/ajax/admin/savePieza.do?categoria=<s:property value="categoryId" />',
                    caption : "Piezas"
                });
        jQuery("#rowed3").jqGrid('navGrid', "#prowed3", {
            edit : false,
            add : false,
            del : false
        });
    })
    
    3 回复  |  直到 8 年前
        1
  •  2
  •   Oleg    14 年前

    你可以使用

    hidden: true, editable: true, editrules: { edithidden: false }, hidedlg: true
    

    在定义中 piezaId (ID)柱。参数 hidedlg 目前不是真正需要的,但如果您决定使用其他jqgrid功能,它可能会很有用。

        2
  •  3
  •   Gregg    14 年前

    在OnElectrow回调中,可以将editURL修改为所需的任何内容,包括传入所需的ID。

    $("#rowed3").jqGrid('setGridParam', {editurl:'whatever/url/you/need/with/the/id'});
    

    jqgrid将为您向该editURL添加所有其他必需的参数。

        3
  •  0
  •   TheRealJAG    8 年前

    在get字符串中传递值对我有效。

    editurl: '/ajax/update?line=1',