Set Url on loadBeforeSend in jqGrid

后端 未结 2 2013
走了就别回头了
走了就别回头了 2021-01-21 07:51

I have a wcf service for a large number of reports that returns json data to my jqgrid. Everything works as expected. However, due to the large number of user inputs for each r

相关标签:
2条回答
  • 2021-01-21 08:20

    If you use mtype: 'GET' and neew just to set additional parameters which will be appended to URL you can use postData parameter of jqGrid. The best results you will have if define the postData as a function (see here for details).

    One more way is to use beforeRequest where this will be set to the grid DOM element and you can access (and change if needed) the url parameter of jqGrid per this.p.url. You can of course use $(this).jqGrid('setGridParam','url',yourNewUrl); instead of direct changing of this.p.url.

    I don't recommend you to use datatype as function in your case. By the way you can't use beforeRequest in case of usage datatype as function.

    0 讨论(0)
  • 2021-01-21 08:26

    I hate answering my own question but this answer provided by Matthew works perfectly. The question is a bit ambiguous but whatever.

    In a nutshell, you need to call an external ajax function from the 'datatype' parameter. Because jqGrid is now loaded (albeit without any data) you can capture the param data from user input (i.e. page 3 of the record set, sort 'desc', etc.) and add it to your json string.

    This makes for a real easy uri route in your service. Hope this helps someone.

    0 讨论(0)
提交回复
热议问题