jqgrid java服务器端分页
我正在尝试将服务器端排序添加到我的网格中,所以我添加了以下内容:
onPaging : function(which_button) {
_$("#myGrid").setGridParam({datatype: "xml"});
_$("#myGrid").trigger('reloadGrid');
}
当我单击下一页按钮时,它会转到我的服务器并再次加载网格,所以我再次看到第一页中的记录。我的问题是如何连接有关网格记录和我的服务器的数据?有服务器端分页的完整示例吗?我还需要将什么传递到我的服务器才能获取下一页的当前记录?我需要向我的网页添加什么以及向服务器页面添加什么?
如有任何帮助,我们将不胜感激,
提前致谢。
I'm trying to add server side sorting to my grid, so I added this:
onPaging : function(which_button) {
_$("#myGrid").setGridParam({datatype: "xml"});
_$("#myGrid").trigger('reloadGrid');
}
and when ever I clicked the next page button it went to my server and loaded the grid again, so I see the records from the first page again. my question is how do I connect the data about the grid records and my server? Is there a full example of server side paging? what else do I need to pass into my server inorder to get the currect records for the next page? what do i neeed to add to my web page and what to the server page?
Any help will be appritiated,
Thank's In Advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请确认您正在执行服务器端排序还是服务器端分页。从问题中我了解到您正在尝试通过单击网格中的下一个/上一个按钮从服务器检索下一页数据。如果您的目标只是获取分页数据,那么以下逻辑将会有所帮助。如果您对服务器端排序+服务器端分页感兴趣,则需要遵循类似的方法。
服务器端分页逻辑:
假设您总共有 1000 条记录,每页必须显示 50 条记录。
我假设您在第一页中显示记录时只提取前 50 条记录,然后单击“下一步”按钮,您希望从数据库中检索要在网格中显示的下 50 条记录。
您不需要 onPaging : 函数。只需设置 paging:true 就足够了。
在带有 getter 和 setter 的 java 类中包含以下变量
之后,您需要进行一些计算,以根据检索到的记录设置网格的字段。
// 假设总共有 1000 条记录。这应该动态设置。目前它被硬编码为 1000。
Please confirm are you doing server side sorting or server side paging. From the question I understand that you are trying to retrieve the next page data from the server on click of next/prev button in the grid. If your objective is just to get the paging data then below logic would help. If you are interested in server side sort + server side paging a similar approach needs to be followed for that.
Logic for Server side paging:
Lets assume you have total of 1000 records which has to be displayed as 50 records per page.
I am assuming that you only pull the 1st 50 records while displaying the records in first page and then on click of next button you want to retrieve the next 50 records to be displayed in the grid from the database.
You don't need the onPaging : function. Just setting paging:true will suffice.
Have following variables in the java class with getter and setter
After that what you need is some calculations to set the fields for the grid as per retrieved records.
// Assuming you have 1000 records in total. This should be set dynamically. For time being it is hardcoded to 1000.