0

I'm trying to use a rest service with jqgrid according to this question and I want to set "DELETE" metod for all my grids, but jqgrid still uses POST as the method for sending delete requests. This how I'm doing it:

$.extend($.jgrid.del, {
mtype: "DELETE"});

and this is my grid instance delete options in navGrid:

{
    url: '../../webresources/routing/phoneNumber',

    serializeDelData: function () {
        return ""; // don't send and body for the HTTP DELETE
    },
    onclickSubmit: function (params, postdata) {
        params.url += '/' + encodeURIComponent(postdata);
    },
    errorTextFormat: function (data) {
        return 'Error: ' + data.responseText;
    }
}

If I set mtype:"DELETE" in navGrid delete options it is working as expected.

Community
  • 1
  • 1
babak
  • 55
  • 1
  • 7

1 Answers1

0

I suppose that you placed the statement $.extend($.jgrid.del, { mtype: "DELETE"}); on the wrong place. Moreover it's dangerous to use non-deep version of $.extend. I'd recommend you to use

$.extend(true, $.jgrid.del, { mtype: "DELETE"});

instead. Moreover you can place mtype: "DELETE" directly in the list of delete options in navGrid.

Please write always, in all your questions, which version of jqGrid and from which fork of jqGrid (free jqGrid, Guriddo jqGrid JS or an old jqGrid in version <=4.7) you use. I develop free jqGrid fork since more as one year and have implemented a lot of new features. Some from new features simplifies the usage of RESTful services. See the answer, which shows how one can use url defined as function for Delete operation and to use url and mtype defined as function for Add/Edit.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • Thanks Oleg. I was using guriddo's version of jqgrid (5.0.1) because it supports bootsrap. I pulled your repository and now it is working as expected. Is it possible to use bootstrap to style your version of jqgrid? Thank you for your good work – babak Feb 07 '16 at 05:50
  • @babak: You are welcome! The latest version (4.12.2-pre), which you can download from GitHub is not final, but you can download it and to use new `guiStyle: "bootstrap"` option. It works currently in combination with `iconSet: "fontAwesome"` only. You could include both `bootstrap.css` and `font-awesome.css` on the HTML page, but including `jquery-ui.css` is not required. **See [the demo](http://www.ok-soft-gmbh.com/jqGrid/OK/formEditOnDoubleClick-bootstrap1.htm)**. I'm still working on the 4.12.2-pre, thus some features are not full finished. – Oleg Feb 07 '16 at 07:55
  • @babak: I'll include support of Bootsrtap with `iconSet: "glyphicon"` (Bootstrap without Font Awesome) after the main part with `iconSet: "fontAwesome"` will be finished. – Oleg Feb 07 '16 at 07:57