我想为 jqGrid 实现删除,我有(示例)2 表请求和项目
请求字段是RequestId
, WayBillNo
,Customer
项目字段是RequestId
, ItemNO
,Quantity
请求表RequestId
是 pk 并且在项目表 pk 中RequestId
,ItemNO
我为项目表编写了这段代码
var requestIdItem=0, itemIdItem=0;
var gridItem = $('#listItem');
gridItem.jqGrid({
url: 'jQGridHandler.ashx',
postData: { ActionPage: 'ClearanceItems', Action: 'Fill', requestId: rowid },
ajaxGridOptions: { cache: false },
datatype: 'json',
height: 200,
colNames: ['RequestId','ItemNo',Quantity],
colModel: [
{ name: 'REQUEST_ID', width: 100, sortable: true,hidden:true },
{ name: 'ITEM_NO', width: 200, sortable: true }
{ name: 'Quntity', width: 100, sortable: true }
],
gridview: true,
rowNum: 20,
rowList: [20, 40, 60],
pager: '#pagerItem',
viewrecords: true,
sortorder: 'ASC',
rownumbers: true,
//onSelectRow: function (id, state) {
// requestIdItem = gridItem.jqGrid('getCell', id, 'REQUEST_ID_ID');
// alert(requestIdItem);
// itemIdItem = gridItem.jqGrid('getCell', id, 'ITEM_NO');
// alert(itemIdItem);
//}
//,
beforeSelectRow: function (itemid, ex) {
requestIdItem = gridItem.jqGrid('getCell', itemid, 'REQUEST_ID_ID');
itemIdItem = gridItem.jqGrid('getCell', itemid, 'ITEM_NO');
return true;
}
});
gridItem.jqGrid('navGrid', '#pagerItem', { add: false, edit: false, del: true }, {}, {}, {
//alert(requestIdItem);
url: "JQGridHandler.ashx?ActionPage=ClearanceItems&Action=Delete&REQUEST_ID=" +
requestIdItem + "&ITEM_NO=" + itemIdItem
}, { multipleSearch: true, overlay: false, width: 460 });
我为项目表编写此代码,现在我想为项目表中的删除项目编写代码我为发送参数值编写此代码
url: "JQGridHandler.ashx?ActionPage=ClearanceItems&Action=Delete&REQUEST_ID=" +
requestIdItem + "&ITEM_NO=" + itemIdItem
但总是向服务器发送 0 值,请帮助我。谢谢大家
EDIT01:我更改删除选项为此:我在此页面中看到http://stackoverflow.com/questions/2833254/jqgrid-delete-row-how-to-send-additional-post-data
用户@Oleg 编写此代码
gridItem.jqGrid('navGrid', '#pagerItem', { add: false, edit: false, del: true }, {}, {}, {
serializeDelData: function (postdata) {
alert(postdata.id);
return ""; // the body MUST be empty in DELETE HTTP requests
},
onclickSubmit: function (rp_ge, postdata) {
// alert(postdata.id);
var rowdata = $("#listItem").getRowData(postdata.id);
alert(rowdata.REQUEST_ID_ID);
rp_ge.url = 'JQGridHandler.ashx?ActionPage=ClearanceItems&Action=Delete&' +
$.param({ rr: rowdata.REQUEST_ID_ID });
// 'subgrid.process.php/' + encodeURIComponent(postdata.id) +
// '?' + jQuery.param({ user_id: rowdata.user_id });
}
//alert(requestIdItem);
// url: "JQGridHandler.ashx?ActionPage=ClearanceItems&Action=Delete&REQUEST_ID=" +
// requestIdItem + "&ITEM_NO=" + itemIdItem
}, { multipleSearch: true, overlay: false, width: 460 })
当发送数据到服务器发送undefined