在jqGrid中请求页面0 [英] Requesting page 0 in jqGrid

查看:96
本文介绍了在jqGrid中请求页面0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从jqGrid中的page = 0开始?

Is it possible to start from page=0 in a jqGrid?

我正在处理无法控制的数据,当我请求页面1时,实际上是从服务器获取页面2,因此,我正在寻找某种方法来实际请求页面0.

I am working with data that is out of my control and when i request page 1 I actually get page 2 from the server, so therefore I am looking for some way to actually request page 0.

据我所知,在 jqGrid中设置页面参数选项设置为零无效.检查请求时,page参数仍为1.

As far as i can see, setting the page parameter in the jqGrid options to zero has no effect. When inspecting the request the page parameter is still 1.

我还试图在初始化后稍后更改page参数.将页面设置为1:

I have also tried to change the page parameter later on after initialization. This sets the page to 1:

grid.setGridParam({page:0}).trigger('reloadGrid');

另一方面,这将请求中的页面成功设置为5:

This on the other hand sets page successfully to 5 in the request:

grid.setGridParam({page:5}).trigger('reloadGrid');

我想对请求第0页进行了一些检查,但有任何解决此问题的想法吗?

I guess there is some check against requesting page 0 but any ideas on how to work around this?

推荐答案

如果我正确理解了您的问题,则可以使用定义为函数的jsonReader .

If I understand your problem correct you can solve it by using serializeGridData event handler and page property in the jsonReader defined as function.

我没有测试您在下面找到的内容,但我希望该代码或经过少许修改的代码都可以工作:

I don't tested what you find below, but I hope either the code or a little modified code should work:

serializeGridData: function(postData) {
    if (typeof(ts.p.postData.page) === "number") {
        postData.page--; // decrease the value of page before sending to the server
    }
    return postData;
},
jsonReader: {
    page: function (obj) {
        return obj.page + 1; // increase the value of page returned from the server
    }
}

这篇关于在jqGrid中请求页面0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆