更新时间:2023-01-24 18:36:05
出现性能问题,我一般都会提出这些步骤:
Having performance issues, I suggest in general about these steps:
到1:你确定你没有不必要的属性,关于你的单元格的文本和事件吗?
To 1: are you sure you have no unnecessary attributes, texts and events concerning your cells?
到2 :这是一个将 autoWidth
设置为false的提示,但在其他线程中没有帮助。 在jQuery DataTables中隐藏列的性能问题
To 2: here is a hint of setting autoWidth
to false, but it didn't help in the other thread. Performance issues when hiding columns in jQuery DataTables
在DataTables API的选项中,还有一种影响性能的可能性: deferRender
: http://datatables.net/reference/option/deferRender - >您确定您的列仅显示吗?也许浏览器必须首先创建HTML,因为它在加载时没有创建?
In the options of DataTables API, there is one further possibility influencing performance: deferRender
: http://datatables.net/reference/option/deferRender -> are you sure your columns are only made visible? Maybe the browser has to create the HTML first, as it was not created while loading?
此外,在DataTables手册/常见问题解答中,是对加速表的解释改变其构建方式: http://datatables.net/faqs/index (向下滚动到DataTables运行缓慢)。
Further, in the DataTables manual/FAQ is an explanation of speeding up the table by altering the way it's built: http://datatables.net/faqs/index (scroll down to "DataTables is running slow").
到3和4:我可以想到有两个html div
旁。 div
1包含列1到5, div
2包含列6到12.然后通过切换 div
2打开和关闭,所有的列将立即可见/不可见。我可以想象,如果你只使用 visibiliy:hidden
和不 display:none
浏览器不需要渲染新的。
To 3 and 4: I could think of having two html div
containers seamlessly laying beside. div
1 contains columns 1 to 5, div
2 contains columns 6 to 12. Then by switching div
2 on and off, all the columns would get visible/invisible at once. I could imagine that if you use only visibiliy:hidden
and not display:none
, the browser doesn't have to render new.