I have a wcf service for a large number of reports that returns json data to my jqgrid. Everything works as expected. However, due to the large number of user inputs for each report query I have elected to use a json string that matches a series 'input models' I have setup on the server. I don't want to mess with long complicated query strings in my routes.
Question: How can I add the jqGrid query string params do my json string I am uploading to the server? I have tried 'loadBeforeSend' but I can't seem to override the ajax url. I can't use a function for the url parameter because the grid params are not available yet. Any ideas? Thanks.
My jqGrid function (shortened for brevity):
function loadGrid() {
var tbl = $('#tbl');
tbl.jqGrid({
loadBeforeSend: function () {
var ai = {
dateFrom: dbDateTime($('#at-datefrom').val()),
dateTo: dbDateTime($('#at-dateto').val()),
sidx: tbl.getGridParam('sortname'),
sord: tbl.getGridParam('sortorder'),
page: tbl.getGridParam('page'),
rows: tbl.getGridParam('rowNum')
};
var newUrl = getBaseURL() + 'ReportingService.svc/report/?json=' + JSON.stringify(ai);
tbl.jqGrid().setGridParam({ url: newUrl });//Everything works perfect up to this point. All the values are in my json string and my url is correct.
},
url: '', //Empty because I need to override it
datatype: 'json',
mtype: 'GET',
ajaxGridOptions: { contentType: 'application/json' },
loadError: function (xhr, status, error) { alert(status + "" + error); }
}).navGrid('#attendance-pager', { edit: false, add: false, del: false });
}