Reputation: 4607
I have setup grid instance something like this:
$("#list").jqGrid({
url:'rest/usertest/users',
datatype: "json",
mtype: "POST",
colNames: ["Username", "Name", "Grouping"],
colModel: [
{ name: "username" },
{ name: "name", width: 90 },
{ name: "grouping", width: 80, sorttype:'string',searchoptions:{sopt:['eq','bw','bn','cn','nc','ew','en']}},
],
pager: "#pager",
rowNum: 10,
rowList: [10, 20, 30],
sortname: "username",
sortorder: "asc",
viewrecords: true,
multiselect: false,
autowidth: true,
height: 'auto',
gridview: true,
multiSort: true
});
jQuery("#list").jqGrid('filterToolbar',{searchOnEnter : false,searchOperators : true});
I am trying to do a server side operand based search via grid. The problem is that it doesn't send any information about the chosen operator to the server-side. The request does not contain any information about the selected operator (eq, bw, bn etc).
I am trying to do so with the toolbar search itself. Am I missing any configuration parameter? Please advice.
EDIT:
I tried the answer given below by @Tomcat, however it still does not work. The search is successful but I am not able to the make the operand based search work on server side.
As in the pic below, there is not info about the chosen operand.
Upvotes: 3
Views: 2225
Reputation: 19146
Having stringResult : true
is necessary.
$('#list').filterToolbar({
groupOp: 'OR',
defaultSearch: "cn",
autosearch: true,
searchOnEnter: true,
searchOperators: true, // activates the operators menu
stringResult : true // activates multi-field search
});
Upvotes: 2
Reputation: 36
Try to add to the grid setup next properties:
searchOperators: true,
search: true,
After that request to the server should contain the next parameters: "filters" - search filter, "sidx" -filed for sorting, "sord" - sorting order ('asc' or 'desc'), '_search' - bool trigger for searching.
Ok, please take a look at this code, it works and send all the necessary information. Pay attention to the jQuery("#list").jqGrid('filterToolbar', { properties.
jQuery("#list").jqGrid('filterToolbar', {
searchOnEnter: false,
searchOperators: true,
multipleSearch: true,
stringResult: true,
groupOps: [{ op: "AND", text: "all" }, { op: "OR", text: "any" }],
defaultSearch: 'cn', ignoreCase: true
});
Hope it will be helpful.
Upvotes: 0