问题
I am using JQGrid to get the date from the RESTFul web services
that i have created on the server
now when i try to hit the url http://www.example.com/event/getAllInfo
, the jqGrid by default appends _search=false&nd=1332922405416&rows=20&page=1&sidx=&sord=asc
to the rest url and because of that my server don't fetch the data back , so
1) how can i remove it
2) and put it back in a url with in such a way that it looks http://www.example.com/event/getAllInfo/false/1332922405416/20/1/0/asc
i can create the url at the server as above but how can i make the jQGrid to use it from RESTful rather then from query string
here is my code
jQuery("#list4").jqGrid({
url:"http://www.example.com/event/getAllInfo",
datatype: "json",
restful: true,
mtype: 'GET',
height: 250,
colNames:['id','title', 'description', 'create date','json','img','video'],
colModel:[
{name:'id',index:'e_info_id', width:60, sorttype:"int"},
{name:'title',index:'e_meta_title', width:90, sorttype:"date"},
{name:'name',index:'e_meta_description', width:100},
{name:'amount',index:'e_info_create_date', width:80, },
{name:'tax',index:'e_meta_JSON', width:80},
{name:'total',index:'e_meta_img', width:80},
{name:'note',index:'e_meta_video', width:150}
],
multiselect: true,
caption: "Manipulating Array Data"
});
回答1:
First of all the RESTFul web services don't mean that you can't send additional parameters to the server. The main idea only to use URL to identify the resource and use different HTTP verbs (request methods) for different operations.
Only if you don't want or don't can to implement server side paging, sorting and filtering of data you can remove any additional parameters from the URL which will be used. Do do this you can just add
postData: ""
as additional parameter. In the case you should use loadonce: true
or at least rowNum: 10000
(or some other large value). In the case will be very important to use gridview: true
as additional parameter (I recommend to use the parameter always). The server should return all the data. The data should be sorted if you would use sortname
parameter.
I would recommend you to add Cache-Control: private, max-age=0
to the header of the server response (see here and here).
UPDATED: I recommend you to read the answer on the question which you ask about the encoding of the URL. Like I wrote you before in the comment I think that the part _search=false&rows=20&page=1&sidx=&sord=asc
is not belong to resource. It's mostly an additional options or properties of the request. You can place the information in the HTTP header inside of loadBeforeSend callback (see here an example), but I don't think that it will be good idea and will simplify the usage of the RESTfull services which you develop. I would recommend you just remove nd=1332922405416
with respect of prmNames: {nd: null}
jqGrid option and use Cache-Control
to control the caching or responses.
来源:https://stackoverflow.com/questions/9903759/remove-extra-query-parameters-from-jqgrid-for-restful-webservice