I find that you not really need to have an event after the searching. At the every search request the data in the grid will be reloaded. So you can use events like beforeRequest
, loadBeforeSend
, serializeGridData
, gridComplete
or loadComplete
.
From your title example I can suppose that you use "Advanced Searching". I want only demonstrate the main idea of the possible solution, so I choosed loadComplete
to implement the capture change:
jQuery('#list').jqGrid({
// ...
loadComplete: function(data) {
var postData = jQuery('#list').getGridParam("postData");
var newCapture = "Title";
if (postData._search === true && typeof postData.filters !== "undefined") {
var filters = jQuery.parseJSON(postData.filters);
newCapture = "Title: [";
var rules = filters.rules;
for (var i=0; i<rules.length; i++) {
var rule = rules[i];
var op = rule.op; // the code name of the operation
if (jQuery.fn.searchFilter && jQuery.fn.searchFilter.defaults &&
jQuery.fn.searchFilter.defaults.operators) {
// find op description
var operators = jQuery.fn.searchFilter.defaults.operators;
for (var j=0; j<operators.length; j++) {
if (operators[j].op === rule.op) {
op = operators[j].text;
//op = $.jgrid.search.odata[j];
break;
}
}
}
newCapture += rule.field + " " + op + " '" + rule.data + "'";
if (i+1 !== rules.length)
newCapture += ", ";
}
newCapture += "]";
}
jQuery('#list').setCaption(newCapture);
}
});
If you don't use "Advanced Searching" you should searchField
, searchOper
and searchString
instead of filters
to build the grid title based on the search cafeteria.
Currently in the example I don't use localizes names for operation, but it's clear that one can do this.