使用 MVCContrib 网格进行服务器端分页
我必须使用存储过程来获取和分页数据。这个特定的存储过程具有各种参数,包括分页信息。显然,分页需要在服务器端完成,用户每次选择新页面时都需要获取一页数据。
我正在尝试使用 MVCContrib 来完成这项工作,但在我看来,网格及其分页器仅支持本地分页和过滤。可用页面的数量取决于集合中已存在项目的数量,或者在我看来是这样。
有没有办法让 MVCContrib 与服务器端分页一起工作?
I have to use stored procedures to fetch and page data. This particular stored procedure has all sorts of parameters, including paging information. Obviously, paging needs to be done server side, one page of data needs to be fetched each time a user selects a new page.
I'm trying to get this work with MVCContrib, but it seems to me that the grid and its pager support only local paging and filtering. Number of available pages is determined by the number of already present items in the collection, or so it seems to me.
Is there a way to make MVCContrib work with server side paging?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
MVCContrib 中有一个名为
CustomPagination
的类。构造函数采用以下参数然后将其传递给网格和寻呼机。
There is a class called
CustomPagination
in MVCContrib. The constructor takes following argumentsThen you pass that to the Grid and Pager.
您需要自己实现 IPagination 接口,将页面参数添加到操作方法中,然后将其传递到存储过程中以获取适当的项目集合。然后根据此内容填充每个 IPagination 属性以及您对存储过程如何工作的了解。
如果您想要更具体的示例,存储过程的示例(或其精简版本)可能会有所帮助。
也许您正在查看使用 LINQ 风格的示例。这并不一定意味着整个集合都在内存中。此外,即使它们在内存中,我仍然会称之为服务器端分页 - 对我来说,Web 应用程序中的客户端分页意味着 javascript。
PS:这可能会帮助您入门,尽管听起来您需要忽略它的实体框架部分:
<一href="http://weblogs.asp.net/rajbk/archive/2010/05/08/asp-net-mvc-paging-sorting-filtering-using-the-mvccontrib-grid-and-pager.aspx" rel =“nofollow”>http://weblogs.asp.net/rajbk/archive/2010/05/08/asp-net-mvc-paging-sorting-filtering-using-the-mvccontrib-grid-and-pager。 aspx
在他们使用“AsPagination()”扩展的地方,您需要调用存储过程并填充您自己的 IPagination 实现。
You'll need to implement the IPagination interface yourself, add a page parameter to your action method then pass this into your stored procedure to get the appropriate collection of items. Then populate each of the IPagination properties from this and your knowledge of how your stored procedure works.
If you want more concrete examples of this, a sample of your stored procedure (or cut down version of it) may be helpful.
Perhaps you're looking at samples that are using a flavour of LINQ. This does not necessarily mean that the entire collection is in memory. Also, even if they are in memory, I would still call this server side paging - To me, client side paging in a web application means javascript.
PS: this may help you get started, though by the sounds of it you will need to ignore the Entity Framework bits of it:
http://weblogs.asp.net/rajbk/archive/2010/05/08/asp-net-mvc-paging-sorting-filtering-using-the-mvccontrib-grid-and-pager.aspx
Where they use the "AsPagination()" extension you'll need to call your stored procedure and populate your own implementation of IPagination.