Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
809 views
in Technique[技术] by (71.8m points)

javascript - Sending additional parameters to editurl on JQgrid

My problem now is trying to send the ID (editable: false) of a row when editing that row.

For example, i have a grid with columns userid(editable: false), username(editable: true), firstname(editable: true), lastname(editable: true). When editing the row the grid is only sending the parameters username, firstname and lastname. In the server side i need the userid to know to which user i've tu apply those new values.

the editUrl looks like:

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

Thanks

This is the full code:

$.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
    });
})
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

in your onSelectRow callback, you can modify the editUrl to be whatever you want, including passing in the ID you need.

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

jqGrid will add all the other nececessary params to that editurl for you.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...