向 JQgrid 上的 editurl 发送附加参数 [英] Sending additional parameters to editurl on JQgrid
问题描述
我现在的问题是在编辑该行时尝试发送该行的 ID (editable: false
).
My problem now is trying to send the ID (editable: false
) of a row when editing that row.
例如,我有一个包含列 userid(editable: false
), username(editable: true
), firstname(editable: true
) 的网格代码>), 姓氏(editable: true
).编辑行时,网格仅发送参数用户名、名字和姓氏.在服务器端,我需要用户 ID 才能知道我将这些新值应用于哪个用户.
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.
editUrl 看起来像:
the editUrl looks like:
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
});
})
推荐答案
可以使用
hidden: true, editable: true, editrules: { edithidden: false }, hidedlg: true
在piezaId
(ID) 列的定义中.参数 hidedlg
目前并不是真正需要的,但如果您决定使用其他 jqGrid 功能,它会很有用.
in the definition of the piezaId
(ID) column. The parameter hidedlg
is currently not real needed, but can be useful if you decide the use other jqGrid features.
这篇关于向 JQgrid 上的 editurl 发送附加参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!