如何在Javascript中为表格设置灵活的分页?
我是一个相对的 JavaScript 初学者。我很喜欢使用文档(document.getElementById(...)
和 document.getElementsByTagName(...)
.. 以及其他文档查询函数。
有人问我为我的团队创建某种表格分页库,我们不使用 jQuery 或任何其他第三方库,所以我会操纵表 dom 或类似的东西来使其在这个库中工作。能够
- 灵活设置分页(每页显示的行数可以通过使用某种文本框进行配置)我查看了一些来源jQuery 分页插件。但我无法理解它。
- 用户应该能够使用一些图标来回导航。更改的页码应该是反映在配置框中,
我不是在寻求解决方案,因为我要学会自己解决这个问题。
根据 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
- 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.
- 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我强烈建议您查看 jquery datatables 插件 http://datatables.net/
I would highly recommend taking a look at the jquery datatables plugin http://datatables.net/
如果您想实现您的 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