1

I have JqGrid set up as a treegrid, and am retrieving row data via ajax through post requests. Two problems: we use anti-forgery tokens to protect any posts to our site...and we need to send filter parameters back to the server, in addition to knowing what row was expanded (so we can return the next part of the hierarchy tree.)

I can modify postData, but I need to inject multiple values into the list, which can change. I tried setting the grid's dataType to "local", switched it back to "json" once the postData had been modified and triggered a reload of the grid, but that didn't work either (and seems like a hack.)

Is there an event I can tie into that allows me to inject data into the postData immediately before the post is sent? If not, does anyone know where in the jqGrid codebase I should add that? The documentation is rather lacking on stuff like this.

Thanks!

Joe the Coder
  • 1,775
  • 1
  • 19
  • 22

1 Answers1

2

I am not sure that I correctly understand your problem. Probably you need just use functions inside of postData (see the answer). One more good callback is serializeGridData. It gives you full control over the data with will be sent to the server. If you want combine both approaches then I would forward you to the answer (or this one).

If you need to set some additional HTTP headers with tokens for example in the Ajax request then loadBeforeSend callback would be the best choice. See the answer for an simple code example.

Community
  • 1
  • 1
Oleg
  • 220,925
  • 34
  • 403
  • 798
  • I had started going through the jqGrid codebase, and found serializeGridData right when you sent your reply...haha. I should be able to just use that event, and instead of using it to serialize the data, just pass it back the new postData object with my additional form parameters. Thanks Oleg! – Joe the Coder Feb 07 '14 at 16:11