搜索结果的分页 [英] Pagination of search results

查看:109
本文介绍了搜索结果的分页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表格,其中用户可以选择搜索选项。当用户点击搜索按钮,
适当的GET控制器的动作被调用:

I have a form where user is able to choose search options. When user clicks "Search" button, an appropriate GET controller's action is invoked:

public ActionResult Search(SearcherViewModel model, int pageNo=1)
        {
         var results = xService.GetSearchResults(model);
         return View("Index", results);
}

GetSearchResults方法不连接到数据库,而是它调用一些第三方Web服务。然而,这不是主要问题。

GetSearchResults method does not connect to the database, but instead it call some third party web service. This however is not the main issue.

因此​​,URL可以看看如下:

Therefore, the url can look as follows:

<一个href=\"http://localhost/Search?startDate=20120210&offerType=3&foodId=4&&Destination=456\" rel=\"nofollow\">http://localhost/Search?startDate=20120210&offerType=3&foodId=4&&Destination=456

我如何能实现对搜索结果进行分页?特别是,我应该如何构建页码以及如何使用我的模型?

How can I implement a pagination of search results? In particular, how should I construct the page numbers and how to use my model?

推荐答案

还挺取决于你有多少东西分页。如果是小的,那么你可以使用preloading保持整个事情在JavaScript内存中,然后根据该JavaScript对象分页。如果您正在寻找潜在的几万或更多的项目进行分页,那么你可以考虑preloading的那部分,然后用ajax就取决于用户如何导航后加载页面。

Kinda depends on how much stuff you are paginating. If it is small then you can hold the whole thing in javascript memory using preloading and then paginate based on the javascript objects. If you are looking at potentially tens of thousands or more of items to paginate, then you may consider preloading part of that and then using ajax to load pages later on depending on how the user navigates.

这篇关于搜索结果的分页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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