简体   繁体   English

在Jqgrid分页中,默认页面值即将为1

[英]Default Page value is Coming as 1 in Jqgrid Paging

I am implementing Jqgrid in Asp.net MVC Application. 我在Asp.net MVC应用程序中实现Jqgrid。 I am doing server side paging and sorting. 我正在做服务器端分页和排序。

Every thing is working fine.i was able to sort and page good. 一切正常。我能够对页面进行排序和分页。 but, the only problem is the intial load. 但是,唯一的问题是初始负载。

When ever the grid is loading , it is skipping one record and then displaying other records. 每当网格加载时,它都会跳过一个记录,然后显示其他记录。

The page parameter that the Jqgrid is sending via Ajax request, the default is coming as 1 instead of -1 or 0. Jqgrid通过Ajax请求发送的页面参数,默认为1而不是-1或0。

Because, in the first load, there are records to be skipped so it should ideally be -1 or 0. 因为在第一次加载中,有一些记录要跳过,所以理想情况下应为-1或0。

Please help me how to sort out this issue.. 请帮助我如何解决此问题。

The value of page parameter which will be sent to the server is 1-based page and not 0-based like you want. 将发送到服务器的page参数的值是基于1的页面,而不是您想要的基于0的页面。 The server should skip (page - 1)*rows records at the beginning of the resulting set and returns rows records. 服务器应在结果集的开头跳过(page - 1)*rows记录,并返回rows记录。 If you are the owner of the code of ASP.NET MVC Application you can just make the above simple calculations on the server side . 如果您是ASP.NET MVC应用程序代码的所有者,则可以在服务器端进行上述简单的计算。 Only if you really don't able to change existing server code you can decrement page value on the client side. 仅当您确实无法更改现有服务器代码时,才可以在客户端上减少page值。 To do this you need just implement serializeGridData callback. 为此,您只需实现serializeGridData回调。 See an example of the code in the answer . 请参阅答案中的代码示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM