views:

3255

answers:

4

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, when I'm making an in-line edit to a row.

I'm using the postData attribute on jqGrid to do this:

Javascript:

$('#tblLines').jqGrid({

    ...

    postData: {MyId : $('#MyId').val()}

    ...

    }

MVC:

public ViewResult EditModifyLine(string id, string quantity, string MyId)

The problem is it's not getting posted to during the POST that jqGrid makes to the controller for the editUrl. My row values are making it up, but the last parameter MyId is always null. I've checked Firebug and confirmed that the POST is sending up only the first two values.

Any ideas? Is it possible to send up the postData values during an in-line edit on a grid?

A: 

I don't think it's supposed to. postData is sent when fetching records. My wild guess is that you should handle beforeSubmitCell instead and manipulate the object to be submitted there.

Craig Stuntz
A: 

I've had some bad experience getting this to actually work. My workaround (which thankfully was accepted as a legitimate UI approach) was to provide save and cancel buttons on row selection.

The saveRow method of jqGrid allows you inject row-specific data for posting. I would suggest looking into that one.

jmarnold
+1  A: 

Unfortunately there was no clean way to do this with the grid. I ended up storing the value needed in Session rather than a hidden field, so I could then access it on the back end for free.

The Matt
A: 

There is something that we call postData, you can manipulate it on the client and send custom data to the server in the form of URL Get parameters, for example.

I think I see something here on stackoverflow that should works:

http://stackoverflow.com/questions/1333684/jqgrid-userdata-posting-null-on-refresh

On a side note, we (Trirand, the guys behind jqGrid), are now working on a ASP.NET WebForms & MVC specific site with examples and even standalone ASP.NET server-side component (similar to GridView) that will work almost codeless with jqGrid.

You can view Alpha of our work here: http://stackoverflow.com/questions/1333684/jqgrid-userdata-posting-null-on-refresh

Excellent, thanks for the response. I'll look forward to that.
The Matt