tags:

views:

47

answers:

2

I am using multisearch on my jqgrid to enable users search data from the server side.
My requirement is, I want to capture the search parameters specified by the user in the search grid as soon as they press the Find button. Accordingly,
a. Is there any event that gets fired when a user clicks the Find button in the search grid? b. how will I capture the search parameters specified in the search grid?

Thanks in advance.

+2  A: 

In case anyone is looking for an answer to the above question:

I found that if we set the closeAfterSearch:true, then clicking 'Find' button triggers onClose event. Similarly, for Reset button, set the closeAfterReset:true, this again triggers onClose event.

jQuery("#list").jqGrid('navGrid', "#pager",{},{},{},{},
{multipleSearch:true,closeAfterSearch:true, closeAfterReset:true,
   onClose:function()
   {
       //do work
       return true; // return true to close the search grid
   }
});
jack
What is the API to determine the search criteria? Ie: say you wanted to print out the user entered search criteria on the screen, how would you do this?
Marcus
Answer below. :)
jack
A: 

Hi Marcus,

Sorry did not visit this thread for a while.

To determine the search criteria that user selected before pressing find use below code:

onClose:function()
{
var ofilter = $("#list").getGridParam("postData"); 
 for (var i = 0; i < ofilter.rules.length; i++) 
 {
  alert(ofilter.rules[i].field); //- field name 
  alert(ofilter.rules[i].data); //- value   
  alert(ofilter.rules[i].op); //- which operation performed  
 }  
}  
jack