在jqgrid中实现删除和编辑操作 [英] Implementing Delete and Edit operations in jqgrid

查看:148
本文介绍了在jqgrid中实现删除和编辑操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下JQgrid实现

  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}
],
标题:管理,
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,记录:TotalRecords,repeatitems:false,id:00}

};

SectorGrid.prototype.SetupGrid = function(selector){
jQuery(selector).html('< table id =grid>< / table>< div id = 寻呼机 >< / DIV>');
var grid = jQuery(#grid)。jqGrid(this.gridConfiguration);

jQuery(#grid)。navGrid('#pager',{edit:false,add:false,del:true,search:false})
};

我想添加一个删除功能,删除调用web服务的url http://localhost/services.svc/sector(id ),服务只需要id,它会处理所有事情通过它我自己也想编辑数据使用不同的网址 http://localhost/services.svc/sector 和这个接收json对象的信息同上面我真的试图配置它,但它不会工作有人可以帮助我在这个,它的剂量问题,如果你使用jqgrid或自定义按钮中的删除选项,但我不想使用editurl属性。



请把完整的示例如何实现这个继续我的代码以上

更新:休息方法

  [WebInvoke(UriTemplate =Sector({iD})/,Method = DELETE,ResponseFormat = WebMessageFormat.Json,BodyStyle = WebMessageBodyStyle.Bare)] 
[OperationContract]
bool DeleteSector(字符串iD)

提前致谢

解决方案

尝试在表单中使用 navGrid

  jQuery(#grid)。jqGrid('navGrid','#pager',
{edit: false,add:false,search:false},{},{},
{//删除参数
ajaxDelOptions:{contentType:application / json},
mtype:DELETE ,
serializeDelData:function(){
return; //不发送和正文为HTTP DELETE
},
onclickSubmit:function(params,postdata){
params.url ='/ Sector('+ encodeURIComponent(postdata)+ ')/';
}
});


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(selector).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) + ')/';
        }
    });

这篇关于在jqgrid中实现删除和编辑操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆