Reputation: 41
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,
Upvotes: 1
Views: 8079
Reputation: 221997
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
UPDATE: In another answer you will find how to delete the last line of the searching dialog (with "Inv No") which are not the part of the searching rules from the postData.filters
.
Upvotes: 1
Reputation: 134167
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.
Upvotes: 0