I am looking to get the full url of the last request to my ajax service made by JqGridincluding page, records per page, search params etc.
Is there any method or collection of methods within the JqGrid api I can use to achieve this?
I am looking to get the full url of the last request to my ajax service made by JqGridincluding page, records per page, search params etc.
Is there any method or collection of methods within the JqGrid api I can use to achieve this?
Share Improve this question edited Aug 29, 2010 at 18:54 Oleg 222k35 gold badges412 silver badges812 bronze badges asked Aug 20, 2010 at 1:40 Luke LowreyLuke Lowrey 3,2053 gold badges29 silver badges40 bronze badges3 Answers
Reset to default 8jqGrid don't save somewhere the full URL appended with all parameters. So it is not possible within the jqGrid API archive this.
To see full URL you can use Firebug, Fiddler or other close tool.
In general it is well known how the url will constructed. How I understand indirectly you want use HTTP GET (mtype: "GET"
). I explain the construction of the URL in case of HTTP GET.
The full URL of the GET requests will constructed from:
url
parameter of the jqGridpostData
parameter of the jqGrid- some additional paremeters which depend on the action used (first grid load, data searching, paring and so on). The names of this additional parameters can be changed by
prmNames
parameter of jqGrid (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options#how_to_overwrite_global_options). For example if you defineprmNames: {sort: "searchIndex", order: "searchDirection", search: null, nd: null}
then parameterssidx
andsord
will be renamed tosearchIndex
andsearchDirection
. Parameters_search
andnd
will not send.
Below you find some typical urls:
- baseurl?_search=false&nd=1250348761396&rows=20&page=1&sidx=&sord=asc
- baseurl?_search=false&nd=1250348761396&rows=20&page=1&sidx=Name&sord=asc
- baseurl?_search=true&rows=10&page=1&sidx=Name&sord=asc&searchField=Manufacture &searchString=Micro&searchOper=bw
The first url requests loading of the first page of data, 20 rows per page, no sorting. The second url has sorting by Name
. The third url contain data filtering (with simple searching) based on the filter "Manufacture
begins with Micro
" and sorting by Name
. Results are paged by 10 rows per page and the first page are requested.
In case of using Advanced Searching or Toolbar Searching instead of Simple Searching the url will looks like a little other. Everithing are documented unter http://www.trirand.com/jqgridwiki/doku.php?id=wiki:jqgriddocs. If you do have additional questions I'll can explain all more detailed.
It is important to understand that parameters used in URL should be encoded. So if you want cunstruct url yourself like
"baseUrl?firstName=" + myFirstName + '&lastName=' + myLastName
you should don't forget to use encodeURIComponent
function to encode myFirstName
and myLastName
. Instead of that you can use jQuery.param
(see why my search code does not work on internet explorer) or better use postData
parameter of the jqGrid (see jqgrid not updating data on reload and How to filter the jqGrid data NOT using the built in search/filter box. In the last case symbols '?' and '&' will be inserted in the url if it is needed and all data values will be encoded with respect of encodeURIComponent
.
I had a similar need and solved it with this:
var myUrl = jQuery("#grid").jqGrid('getGridParam', 'url');
myUrl += "?myextraparam=something";
var postData = jQuery("#grid").jqGrid('getGridParam', 'postData');
$.each(postData, function(key, value) {
myUrl += "&"+key+"="+encodeURIComponent(value);
});
//alert(myUrl);
For me, the above got all I needed including items from the search toolbar if used. The ?myextraparam=something
should be replaced with any extra parameters you want to pass.
Here is the simple answer. JQGrid will append to your query strings.
url: "/CaseManagement/Shipping/GetLastShipments?StudentID=" + GetSelectedStudentID(),