Skip to content Skip to sidebar Skip to footer

Update And Delete Does Not Work In Jqgrid

I am working on web api project and I want implement grid with CRUD operations. These are my web api methods: [HttpGet] public HttpResponseMessage GetAllPosting() {} [HttpGet] pub

Solution 1:

The main error in your code consist from the usage afterSubmit. The callback will be used after the response will be get from the server. I suppose that you just wanted to use another callback onclickSubmit, but you used the wrong one.

The correct onclickSubmit callback for Add/Edit could be the following

onclickSubmit: function (options, postdata, formOper) {
    options.url = API_URL + "/" + encodeURIComponent(postdata[this.id + "_id"]);
    options.mtype = formOper === "add" ? "POST" : "PUT";
}

The options of Delete dialog:

{
    mtype: "DELETE",
    serializeDelData: function () {
        return""; // the body MUST be empty in DELETE HTTP requests
    },
    onclickSubmit: function (options, postdata) {
        options.url = API_URL + "/" + encodeURIComponent(postdata);
    }
}

If the value of API_URL already contains / at the end of the string, then you should replace API_URL + "/"to API_URL in the code fragments above.

Post a Comment for "Update And Delete Does Not Work In Jqgrid"