如何处理排序、分页和过滤参数?

发布于 2024-10-07 17:38:59 字数 348 浏览 1 评论 0原文

这是常见的事情:您有一个具有多个属性的项目列表。您可以:

  • 根据每个属性对列表进行排序,按升序和降序
  • 过滤(搜索)项目,再次在所有属性上
  • 在不同结果页面之间导航

所有这些都为给定页面提供了不同的参数:

  • 排序属性 的属性名称和值的排序顺序
  • 以及过滤
  • 页码

对您如何处理页面之间所有这些参数的传播?假设您可以编辑一项,当您返回时,您希望进入原来的页面。

您是否只需将所有参数放入 url 中(并将它们作为“返回参数”传递到编辑页面)?您是否在会话中添加了一些(也许是排序和过滤参数)?

This is the usual thing: you have a list of items with several attributes. You can :

  • sort the list according to each of the attributes, in both ascending and descending order
  • filter (search) the items, again on all attributes
  • navigate between different pages of results

All of this gives you differents parameters for a given page:

  • sorting attribute and sorting order
  • pairs of attribute name and values for the filtering
  • page number

How do you handle the propagation of all these paramters between your pages ? Let's say you can edit one item, and when you go back, you'd like to get on the same page you where.

Do you simply put all parameters in the url (and pass them as "return parameters" to the edit page) ? Do you put some in the session (maybe sort and filter parameters) ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无畏 2024-10-14 17:38:59

我喜欢将它们作为 URL 的一部分,这样如果有人为该页面添加书签或通过电子邮件发送该页面的链接,它就会以完全相同的方式呈现该页面。如果您依赖于会话状态,则无法做到这一点。

I like to make them part of the URL so that if someone bookmarks the page or emails a link to the page, it will render the page exactly the same way. You can't do that if you depend on session state.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文