简体   繁体   English

分块渲染大型HTML表

[英]Rendering large HTML table in chunks

I'm writing a Javascript based table widget that I hope to be capable of handling basically a limitless amount of data. 我正在编写一个基于Javascript的表小部件,希望基本上能够处理无限量的数据。 To do this, the table will make Ajax requests for data only as it is needed (when scrolled into view). 为此,该表将仅在需要时(滚动到视图中时)向Ajax请求数据。 I have the basic idea working, but one issue I'm struggling with is the resizing of table columns. 我有基本的想法,但是我正在努力解决的一个问题是表列的大小调整。

Since only a section of all the rows is actually rendered at any time, the table tends to reflow as the max width of the columns changes. 由于实际上在任何时间实际上仅渲染所有行的一部分,因此,当列的最大宽度改变时,该表趋于重排。

I thought about iterating the table cells each time the table is rendered, and remembering the "max width" of each column. 我考虑过在每次渲染表时都对表单元进行迭代,并记住每列的“最大宽度”。 There would still be some reflowing, but once you've seen the widest td, it should stop. 仍然会有一些重排,但是一旦您看到最大的td,它应该停止。 The issue is that this seems to be a kind of clunky solution, and I find myself writing more code than I'd like to handle it. 问题在于,这似乎是一种笨拙的解决方案,我发现自己编写的代码超出了我的意愿。

Has anyone run into this before, or have any simpler ideas on how to handle it? 有没有人遇到过这个问题,或者对如何处理有更简单的想法?

For consistency, I would lock the column width to what it is on the first view of the table. 为了保持一致,我将列宽锁定为表格第一个视图上的宽度。 That way, there's no shifting at all. 这样,根本没有任何变化。

You should also give the developer a way to specify a static column width for the columns so that they can size them appropriate to their data once they know the widths. 您还应该为开发人员提供一种为列指定静态列宽度的方法,以便一旦知道宽度,它们就可以根据其数据调整大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM