i have the following JQgrid implementation
colModel: [
{ name: 'NameEn', index: 'NameEn', width: 100, align: 'left' },
{ name: 'Desc', index: 'Desc', width: 100, align: 'left' },
{ name: 'ID', index: 'ID', width: 100, align: 'left', hidden:true }
],
caption: "Management",
gridview: true,
rownumbers: true,
rownumWidth: 40,
scroll: 0,
rowNum: 100,
sortname: 'ID',
pager: '#pager',
sortorder: "asc",
viewrecords: true,
autowidth: true,
width: '100%',
height: '100%',
jsonReader: { root: "GridData", page: "CurrentPage", total: "TotalPages", records: "TotalRecords", repeatitems: false, id: "00" }
};
SectorGrid.prototype.SetupGrid = function (selector) {
jQuery(s开发者_运维百科elector).html('<table id="grid"></table><div id="pager"></div>');
var grid = jQuery("#grid").jqGrid(this.gridConfiguration);
jQuery("#grid").navGrid('#pager',{edit:false,add:false,del:true,search:false})
};
i want to add a delete functionality, the delete call a webservice with the url http://localhost/services.svc/sector(id) and the service just take the id and it will handle everything by it self also i would like to edit data using differnt url http://localhost/services.svc/sector and this receives json object with the same information above. i really tried to configure it but it wont work can somebody help me in this, it dosent matter if u used the delete option in the jqgrid or custom buttons but i dont want to use the editurl property.
please put a full example how to implement this continue to my code above
UPDATED: Rest Method
[WebInvoke(UriTemplate = "Sector({iD})/", Method = "DELETE", ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare)]
[OperationContract]
bool DeleteSector(string iD)
thanks in advance
Try to use navGrid
in the form
jQuery("#grid").jqGrid('navGrid', '#pager',
{edit: false, add: false, search: false}, {}, {},
{ // Delete parameters
ajaxDelOptions: { contentType: "application/json" },
mtype: "DELETE",
serializeDelData: function () {
return ""; // don't send and body for the HTTP DELETE
},
onclickSubmit: function (params, postdata) {
params.url = '/Sector(' + encodeURIComponent(postdata) + ')/';
}
});
精彩评论