I use the most excellent jqGrid plugin and found a lot of help on this site by doing a search, but I found a problem that I cannot solve or find a solution. This will be my first post here.
I use filterToolbar to do a search in my grid. Due to the nature of the back side, I need to interact, I unanble to use the filters that jqGrid provides, and instead I need to intercept the search and change the postdata before sending. I do this using the filterToolbar "beforeSearch" option as follows:
$("#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;
}});
, .
, , POST . , beforeSearch() , afterShowSearch onClose . , ?