Instead of setting the url you should try something like this.
I am using this for custom drop downs that I add to the grid. Basicaly I conditionaly add 2 drop downs to the top toolbar section of the grid for quick searching.
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 wanted your 2 fields in the top toolbar as well you will need to add the following to your table options.
toolbar: [true, "top"],
First add this to your table definition.
beforeRequest: myBeforeRequest(this),
Then define your myBeforeRequest function 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 could do the same for your 2 searching fields even clearing them from the parameters if they are blank. This would result in the same url that you are manualy editing now.
GetRecords.aspx?InActive=0&State=O&StateCol=9 is what I am currently getting at the server.