1

我正在使用 JQGrid 从RESTFul web services我在服务器上创建的日期中获取日期

现在,当我尝试点击 urlhttp://www.example.com/event/getAllInfo时,默认情况下 jqGrid 会附加_search=false&nd=1332922405416&rows=20&page=1&sidx=&sord=asc到其余 url,因此我的服务器不会取回数据,所以

1) 我怎样才能删除它
2) 并把它放回一个 URL 中,它看起来像 http://www.example.com/event/getAllInfo/false/1332922405416/20/1/0/asc

我可以像上面那样在服务器上创建 url,但是我怎样才能让 jQGrid 从 RESTful 而不是从查询字符串中使用它

这是我的代码

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"
    });
4

1 回答 1

3

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.

于 2012-03-28T09:07:52.657 回答