I am using the most excellent jqGrid plugin, and have found lots of help on this site by searching, but I have found a problem I cannot solve, or find a solution to. This will be my first post here.
I am using a filterToolbar to do some searching of my grid. Because of the nature of the back end I need to interact with, I am unanble to use the filters that jqGrid provides, and instead need to intercept the search and modify the postdata before submitting. I do this with the filterToolbar option "beforeSearch" like this:
$("#SC_grid").jqGrid('filterToolbar', {stringResult: true, searchOnEnter: true, defaultSearch : "cn", beforeSearch: function() {
var postData = $("#SC_grid").jqGrid('getGridParam','postData');
var newPostData = '1=1';
var searchData = jQuery.parseJSON(postData.filters);
for (var iRule=0; iRule<searchData.rules.length; iRule++) {
newPostData = newPostData + " AND " + searchData.rules[iRule].field + " LIKE '%" + searchData.rules[iRule].data + "%' ";
}
$("#SC_grid").jqGrid('setGridParam',{postData: { filter: newPostData, filters: ''} } );
return false;
}});
This works great for me to build a portion of my select before submission. I would also like to use the advanced search in the same way, but Cannot figure out how to intercept the POST before submission. There does not appear to be a beforeSearch() option abailable, and the afterShowSearch or onClose options dont have the right timings. ANy suggestions on how to proceed?
Mark