Instead of setting a URL, you should try something like this.
I use this for custom dropdowns that I add to the grid. Basicaly I conditionally add 2 drop-down lists to the top of the toolbar for quick searches.
var toolbarspan = $("<span>"); if (tblDef.State != null) { $("<label>").attr("for", "selectState").append(" State: ").appendTo("#t_colch") $("<select>").attr("id", "selectState") .append($("<option>").attr({selected: true, value: "O"}).append("Open")) .append($("<option>").attr("value", "C").append("Closed")) .append($("<option>").attr("value", "B").append("Both")) .change(selChange) .appendTo("#t_colch") } $("<label>").attr("for", "selectInActive").append(" InActive: ").appendTo("#t_colch") $("<select>").attr("id", "selectInActive") .append($("<option>").attr({selected: true, value: "0"}).append("Active")) .append($("<option>").attr("value", "1").append("InActive")) .append($("<option>").attr("value", "B").append("Both")) .change(selChange) .appendTo("#t_colch"); }
If you need your 2 fields on the top toolbar, you need to add the following parameters to the table.
toolbar: [true, "top"],
First add this to the table definition.
beforeRequest: myBeforeRequest(this),
Then define the function myBeforeRequest something like this.
function myBeforeRequest(grid) { $(grid).jqGrid("setPostDataItem", "InActive", 0); var chkVal=""; if ($("#selectInActive").length > 0) { chkVal = $("#selectInActive").val(); if (chkVal == "B") $(grid).jqGrid("removePostDataItem", "InActive"); else $(grid).jqGrid("setPostDataItem", "InActive", chkVal); } if (tblDef.State != null) { $(grid).jqGrid("setPostDataItem", "StateCol", tblDef.State); $(grid).jqGrid("setPostDataItem", "State", "O"); if($("#selectState").length > 0) { chkVal = $("#selectState").val(); if (chkVal == "B") $(grid).jqGrid("removePostDataItem", "State"); else $(grid).jqGrid("setPostDataItem", "State", chkVal); } } }
You can do the same for the two search fields, even clearing them of the parameters if they are empty. This will result in the same URL that you are manually editing now. GetRecords.aspx? InActive = 0 & State = O & StateCol = 9 is what I am currently getting on the server.