开发者

Jquery JqGrid data source url format

I have an html page with a jqgrid. These hqgrid retreve data in json from a php script. jQgrid retrieve data by default requesting this url:

http://localhost/projects/gesti开发者_运维问答onalePreventivi/retrieve/imprese/?_search=false&nd=1311285005780&rows=10&page=1&sidx=id&sord=desc

but I would this url modified in this mode:

http://localhost/projects/gestionalePreventivi/retrieve/imprese/false/1311285005780/10/1/id/desc

This is a little part of my code:

jQuery("#tabImprese").jqGrid({
                url:$myurl,
                datatype: "json",
                height: 150,
                .............
  });

How can I do it? Thank you so much.


I don't think that the usage of url in the form in which you as describe is a good idea. The way seems me not good from the architecture point of view.

Nevertheless from the technical side the dynamic modification of the url is do possible. One can use beforeRequest event like the following:

beforeRequest: function() {
    var p = this.p, pd = p.postData;
    p.url = '/base/' + pd.rows + '/' + pd.page + '/' +
            encodeURIComponent(pd.sidx) + '/' + pd.sord;
    p.postData = {};
}

In the way the URL used will be like you as need: see the demo here. Using Fiddler or Firebug for example you can verify which URL will be used.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜