如何在Javascript中为表格设置灵活的分页?

发布于 2024-12-03 13:26:55 字数 621 浏览 0 评论 0原文

我是一个相对的 JavaScript 初学者。我很喜欢使用文档(document.getElementById(...)document.getElementsByTagName(...).. 以及其他文档查询函数。

有人问我为我的团队创建某种表格分页库,我们不使用 jQuery 或任何其他第三方库,所以我会操纵表 dom 或类似的东西来使其在这个库中工作。能够

  1. 灵活设置分页(每页显示的行数可以通过使用某种文本框进行配置)我查看了一些来源jQuery 分页插件。但我无法理解它。
  2. 用户应该能够使用一些图标来回导航。更改的页码应该是反映在配置框中,

我不是在寻求解决方案,因为我要学会自己解决这个问题。

根据 nnnn 的观察进行更新,

我不确定该采取什么方法,因为我没有考虑过这种可能性。大多数时候,我们只有大约 2000 条记录可以显示。我想如果加载不会占用太多内存,我宁愿提前加载,然后尝试对其进行分页。不过,我会选择推荐的任何内容。

I am a relative JavaScript beginner. I am comfortable working with documents (document.getElementById(...) and document.getElementsByTagName(...).. and other document querying functions.

I have been asked to create some sort of a table pagination library for my team. We don't use jQuery or any other third party libraries. So I would have manipulate the table dom or something like that to make it work. In this library, I would have to be able to

  1. set up flexible pagination (Number of rows to be displayed per page may be configured by using some sort of a text box) I took a look at some of the sources jQuery Pagination Plugin. But I can not understand it.
  2. The user should be able to navigate back and forth using some icons. The page number changed should be reflected in the configuration box.

I am not asking for solutions because I would learn to do this on my own. How can I start working on this issue?

Update after observations from nnnn

I am not sure what approach to take, as I had not considered that possibility. Most of the times, we have only about 2000 records to display. I guess if the load does not take too much memory, I would prefer to load before hand and then try to paginate it. Although, I will go with whatever is recommended.

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

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

发布评论

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

评论(2

清旖 2024-12-10 13:26:55

我强烈建议您查看 jquery datatables 插件 http://datatables.net/

I would highly recommend taking a look at the jquery datatables plugin http://datatables.net/

橘亓 2024-12-10 13:26:55

如果您想实现您的 UI 并且只需要一个对象来处理分页逻辑,请参阅此库: https:// /github.com/pagino/pagino-js

If you want to implement your UI and just need an Object to handle pagination logic please see this library: https://github.com/pagino/pagino-js

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