views:

37

answers:

2

So, there is a jqGrid, with declaration, smth like:

$("#grid").jqGrid({
...
bunch of stuff
...
).searchGrid({ multipleSearch: true });

which is fine, when I click Search button, it brings me modal form with I guess first column and a dropdown of sopts: searchoptions: { sopt: ['eq', 'ne', 'cn']}. Now, i want to be able to display a couple of such fields by default not just one. I know I can add those later, by clicking Add, but I want to display them by default.

Having toolbar search is not an option.

Thanks in advance,

A: 

You cannot do this using the jqGrid API. Instead, you will have to use the afterShowSearch event to call a function after the search dialog is displayed. In that function you could programmatically add new rows, setting each one to the desired values.

Justin Ethier
Thanks Justin, this is the way to go, I hoped I can avoid doing this.
msqsf
+1  A: 

Look at the Toolbar Searching. It shows one field per searchable column. If you use additionally stringResult:true option, you will receive the most compatible results to the Advanced Searching. By the way it you include both features Toolbar Searching and Advanced Searching (multipleSearch: true) the advanced searching dialog will be initialized with the last searching results from the Toolbar Searching. So you will have two or three rows in the Advanced Searching at the beginning.

UPDATED: The reason why after the usage of the Toolbar Searching the dialog with the Advanced Searching will be displayed not empty is that both use filters parameters of the postData. So if you initialize the postData you can receive a good starting point. See on the demo. You will see

alt text

Oleg
Cool man, actually, I've done that using solution Justin provided and it works fine, however, tried yours as well - easy. Very easy. Thanks!
msqsf