Reputation: 1
I have jqGrid 4.1.2 and Iam trying to force filters to be triggered on $(document).ready(
What I want to achieve is to fill one of filtering fields with values and "press enter" so jqGrid would filter it out.
I have passed values to the page by GET, propagated the filter field value like this:
var filteritem = document.getElementById("gs_fieldToBeFilteredID");
filteritem.value = "MY filter value";
It causes that filter field is filled with "My filter value". But now Iam trying to trigger "enter press" on the end of the document like this:
$(document).ready(function () {
$("#myGrid")[0].triggerToolbar();
}
);
I have tried also
jQuery("#myGrid").jqGrid("filterToolbar");
with NO effect. I also put above code in jQGrid loadComplete event with NO effect either. Filter is filled but I "can't" force it to trigger filtering ... any ideas ?!
I would apprecieate any help. Best regards
Upvotes: 0
Views: 4672
Reputation: 221997
It seems to me that the old demo from the answer is what you need.
After you set value
on the <input>
element you could trigger change
filter and then use
$(filteritem).focus().trigger({ type : 'keypress', charCode : 13 });
Depend on where you trigger the keypress
event you could need to do this in separate thread. So it could be that you will need to do this in the setTimeout
like I did it in the demo.
Upvotes: 2
Reputation: 44
You Should be able to add post data to the grid, that is what you want so you don't need to retrigger the grid to reload. It will get it within the inital request.
Here is the full article: http://www.trirand.com/jqgridwiki/doku.php?id=wiki:post_data_module
Ive done it with "before request" event, setting up an function that adds the data that you want.
function jqGridBeforeRequest()
{
$(this).appendPostData(<JSON/object data here>);
}
Upvotes: 0