i have a page with a jqgrid on it with filter row at the top. I want to have a link on another page that loads this grid page but with a filter set on one of the columns. is that possible to do from a link or any other workaround people can suggest?
You can try to use dataInit
property of searchoptions
in the colModel
. This function has one parameter elem
. The $(elem)
will represent the input
html element which you can initialize with any data which you need.
UPDATED: Try to include following option in colModel in the description of the column where you want set the filter:
searchoptions:{
dataInit:function(elem){
$(elem).val("Test");
setTimeout(function(){
$(elem).focus().trigger({ type: 'keypress', charCode: 13 });
},500);
}
}
in this example I set "Test" text as the filter and simulate press enter key. I suppose that searchOnEnter
set to default value true
. The forwarding of the filter string (like "Test") is very depended on the structure of your program, but I hope that it can be easy implemented.
UPDATED 2: Probably there are different understanding how should be understand "a page with a jqgrid on it with filter row at the top". I read it like a setting of filter in the filter toolbar, because the filter toolbar will be added as a row on the top of grids rows. My sollution live can be seen here http://www.ok-soft-gmbh.com/jqGrid/CustomFilter.htm.
You can modify the url that jqGrid calls, and add the filter option to the querystring, then handle it on the server side.
$(link).click(function(){
$(".mygrid").jqGrid('setGridParam',{url:"server.php?useMyFilter=1"})
});