Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using jqGrid userdata

I have a jqGrid on an ASP.Net MVC view. I want to use to pass the value of a hidden text control on the page as an additional parameter to a jqGrid method.

I have the following hidden text field:

<div>
<%= Html.Hidden("contactId", Model.ContactId) %>
</div>

and I want to do something like:

userdata: {contactId : jQuery('#contactId')}

in the jqGrid call. The Controller Action method has the following signature:

public ActionResult SearchResult(string sidx, string sord, int page, int rows, object userdata)

But when I run it, userdata in the C# code just says System.Object when I inspect it in the debugger, and I don't think I can get anythings useful out of it.

Any ideas where I have gone wrong?

like image 786
Colin Desmond Avatar asked Jun 11 '09 14:06

Colin Desmond


1 Answers

The jqGrid property you want is postData. UserData goes the other way.

Change your call to JqGrid to include:

postData: {contactId : jQuery('#contactId').val()}

Then change the signature of your action to take a contactId:

public ActionResult SearchResult(string sidx, string sord, int page, int rows, 
    int contactId)

I guessed at the type. Use the real type in place of int.

like image 148
Craig Stuntz Avatar answered Oct 20 '22 06:10

Craig Stuntz