jquery加载大数据

发布于 2024-10-10 16:09:00 字数 195 浏览 7 评论 0原文

我有一个返回数据的 Web 服务,数据集相当大,可能有 600 行、20 列。 在 Jquery 代码中将此数据加载到 html 表中最快最有效的方法是什么?

我尝试通过循环返回的数据并在字符串中创建表 DOM 来创建表 html,但循环部分非常慢。我听说过 Jquery 模板,但我不确定这项技术对于大量数据来说是否足够快......

谢谢

I have a web service that returns data, quite a large set, could be 600 rows, by 20 columns.
What is the fastest most efficient way to load this data into an html table in Jquery code?

I tried creating the table html by looping through the data returned and creating a table DOM inside a string, but the looping part is very slow. I have heard of Jquery Templates, but I am not sure this technology is fast enough for large sets of data....

Thanks

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

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

发布评论

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

评论(4

慕巷 2024-10-17 16:09:00

您是否可以更改 Web 服务或让其他服务调用它并解析数据服务器端并返回 HTML?在客户端处理 JSON 将成为您的瓶颈。如果您可以让服务返回所需的 HTML,那么它在客户端就是一个简单的 element.html(data)

编辑:返回 JSON 或 HTML 的问题以及各自的优缺点已经在这里讨论了很多:
123, 45

Is it possible for you to alter the web service or have another service call it and parse the data server side and return HTML? Processing the JSON on the client-side is going to be your bottleneck. If you can have the service return the required HTML to you, then it's a simple element.html(data) on the client side.

Edit: The question of returning JSON or HTML and the pros and cons of each have been discussed here quite a bit:
1, 2, 3, 4, 5

半岛未凉 2024-10-17 16:09:00

看来这是一个设计问题。一次加载 600 x 20 个数据项并不是一个好主意。考虑到系统资源较低的客户端(例如袖珍 PC 或 TC(瘦客户端))将难以访问此类页面。

您需要缓存 Web 服务数据并根据用户操作将其分块加载到客户端浏览器中。您可以使用一些 Ajax 控件来执行此操作。

It seems this is a matter of design. loading 600 x 20 data items at once is not a good idea. Consider clients with low system resources like pocket PCs or TCs (thin client) would suffer to visit such a page.

You need to cache webservice data and load it in chunks into client browser based on the user action. You can use some Ajax controls to do so.

心碎的声音 2024-10-17 16:09:00

如果您的目标是让用户能够尽快与数据交互,您可能需要考虑诸如无限滚动(也称为连续滚动)模式之类的东西,以便您根据用户的滚动需要构建网格而不是花费全部时间预先渲染网格。

一些链接:

http://www.infinite-scroll.com/

http://net.tutsplus.com/tutorials/javascript -ajax/如何创建无限滚动网络画廊/

If your goal is to have the user be able to interact with the data as fast as possible, may be you want to consider something like infinite scroll (also called continuous scroll) pattern so you build the grid as needed from the scrolling of the user and not spend the whole time rendering the grid upfront.

Some links:

http://www.infinite-scroll.com/

http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-an-infinite-scroll-web-gallery/

琉璃梦幻 2024-10-17 16:09:00

我认为这是 JSON DB 可能最有用的地方。您可以编写一个服务器端页面,以 json db 格式的数据响应几行。然后执行您自己的 ajax 代码来加载行并在您选择的显示模型中处理它们,例如您自己的 ; 与 "overflow:auto;" 并以块的形式向该表添加行..或者使用已经建议的“无限滚动”之类的内容。

I think this is where JSON DB might be best useful... you could write a server-side page that responds with json db formatted data for a few rows.. then do your own ajax code to load the rows and process them in your choice of display model like your own <table> with "overflow:auto;" and add rows to that table in chunks.. or use something like 'infinite scroll' already suggested.

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