I am using the JQSuite's Trirand.Web.MVC dll for my integration of JQGrid into my MVC 3 application.
I am using the HTML helper for JQGrid, so in my View I have the following:
@Html.Trirand().JQGrid(Model.MyGrid, "Grid")
I know I can reload my grid on a button click by using the following code:
$("#Grid").trigger("reloadGrid");
This WILL reload the grid, calling the Action method I specified in my contoller code for setting up the JQGrid.
I have other controls on the page that I use for searching/filtering, these get passed to the action method fine.
I found the setGridParam method, which seems to indicate you can do something like:
$("#Grid").setGridParam({ someParam: 'blah' }).trigger("reloadGrid");
or this:
$("#Grid").jqGrid('setGridParam', { postData: { someParam: 'somevalue'} }).trigger("reloadGrid");
but my someParam parameter on my action method does not get filled with either method
How can I set these on the JQGrid so that they are picked up by Action method when doing the reload?
UPDATE: I have now tried this method for another parameter and it DOES work!
So now I have:
$("#Grid").jqGrid('setGridParam', { postData: {
someParam: 'somevalue',
paramTwo: ' some value',
paramThree: 'some other value'
} }).trigger("reloadGrid");
someParam does not work, but paramTwo and ParamThree DO work.
strange!
What could stop one parameter from working?
UPDATE2: Using Oleg's suggestion as follows:
var myGrid = jQuery("#Grid").jqGrid({
postData: {
someParam: function () { return $("#txtBox1").val(); },
paramTwo: function () { return $("#txtBox2").val(); },
paramThree: function () { return $("#txtBox3").val(); }
}
});
myGrid.trigger('reloadGrid');
...NONE of the values get sent through. I have validated the JQuery returns the correct values before it does the reload.