gpt4 book ai didi

javascript - 将附加参数发送到 JQgrid 上的 editurl

转载 作者:行者123 更新时间:2023-11-29 17:31:53 24 4
gpt4 key购买 nike

我现在的问题是在编辑该行时尝试发送该行的 ID ( editable: false)。

例如,我有一个包含用户 ID(editable: false)、用户名(editable: true)、名字(editable: true)、姓氏(editable: true)列的网格。编辑行时,网格仅发送参数用户名、名字和姓氏。在服务器端,我需要用户 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
});
})

最佳答案

在您的 onSelectRow 回调中,您可以将 editUrl 修改为您想要的任何内容,包括传入您需要的 ID。

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

jqGrid 将为您将所有其他必要的参数添加到该 editurl。

关于javascript - 将附加参数发送到 JQgrid 上的 editurl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3176157/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com