Brendan Abel
Brendan Abel

Reputation: 37559

jqgrid custom ajax request

I'm trying to use jqgrid with an existing REST framework for querying and filtering data.

Is there a way in jqgrid to customize the ajax request data/parameters? It looks like you can set the url and mtype (ie. GET, POST), but I'm not sure how to set the parameter data. The REST API I'm using has it's own filtering and sorting syntax. I would need to convert the param data from jqgrid into a format that is usable by the REST API.

For reference, I'm thinking of something similar to this https://datatables.net/reference/option/ajax (the function form of the option), where you are able to make the ajax request yourself and pass the results to a callback.

Upvotes: 0

Views: 733

Answers (1)

Oleg
Oleg

Reputation: 222007

To customize properties of jQuery.ajax one can use ajaxGridOptions parameter. To customize Ajax call used for loading of the grid one can use serializeGridData callback. The serializeGridData callback get object with the parameters which will be send by default (like data parameter of jQuery.ajax). The value, returned from the callback, will be used as data parameter of jQuery.ajax). You can find examples of an implementation of serializeGridData in the answer, this one, this one, this one and many other.

Upvotes: 1

Related Questions