简体   繁体   English

使用Datatables jQuery插件提高更新DOM的性能

[英]Improve performance updating the DOM using Datatables jQuery plugin

I wonder if there's any way to speed up fnUpdate function when applying it to many rows. 我想知道将fnUpdate函数应用于多行时是否有任何方法可以加快它的速度。 In my case I am using it to update for example 10 cells of 10 different rows and I am noticing it is not so fast as expected. 以我为例,我使用它来更新10个不同行的10个单元格,但我注意到它的速度不如预期的快。 Its a bit laggy. 它有点落后。

I've seen than a common technique to improve the performance when updating the DOM is to to do it at once instead of looping. 我已经看到 ,在更新DOM时提高性能的一种通用技术是立即执行而不是循环执行。 This way, the browser will only reflow the page once and will speed up the process. 这样,浏览器将只对页面进行一次重排,从而加快了处理速度。

Is there any way to do it in datatables plugin making of of fnUpdate function ? fnUpdate函数的数据表插件制作中有什么方法吗? Thanks. 谢谢。

It might be helpful that you try the 4th and 5th option of fnUpdate, which disables updating the entire table right after updating the cell. 尝试使用fnUpdate的第4个和第5个选项可能会有所帮助,该选项会在更新单元格后立即禁用更新整个表。 You can do the whole table update when all changes are done. 完成所有更改后,您可以更新整个表。

for(i = 0; i < rows ; i++) for(i = 0; i <行; i ++)
{ {
dataTable.fnUpdate( "Sample Data", i, 3, false, false ); dataTable.fnUpdate(“ Sample Data”,i,3,false,false);
} }
dataTable.fnDraw(); dataTable.fnDraw();

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

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