table.column(x).visible slow

table.column(x).visible slow

pclaarpclaar Posts: 8Questions: 4Answers: 0

Hello,

I've been happy with DataTables, an amazing library, but have had performance problems since 1.10.0. The problems are found in loops where I'm showing/hiding columns.

Here's an example: http://www.schooldigger.com/go/WA/compare/0771001263/schoolcompare.aspx
Non-minified source code is at: http://schooldigger-claarwarellc.netdna-ssl.com/clientscript/SchoolDigger.1.64.js

Note that the data table takes a long time to load and display (in my case 10+ seconds). Clicking on the tabs (like "Test Scores") is also pretty slow.

After some profiling, believe that the culprit is within the function cShowColumnSet with each call to cTable.api().column(x).visible(boolean). I've also tried replacing these calls with cTable.fnSetColumnVis(x, boolean, false) (this delays rendering until I call draw) but render times do not improve.

I've run just fine with this code on previous versions of DataTables. Any thoughts on what I can do to increase performance?

Thanks in advance!

Pete

Answers

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    Hi Pete,

    Interesting on. I think this is actually a bit of a deficiency in the new API. Previously you had the ability to tell DataTables to not recalculate the column sizes until you had set all the columns you want to - that functionality doesn't actually exist in 1.10 now and it will calculate the column sizes on every call, which is why it is so darn slow.

    I need to look at adding that ability back in!

    Thanks for flagging this up.

    Allan

  • allanallan Posts: 61,650Questions: 1Answers: 10,094 Site admin

    Committed and now in the nightly :-)

    Allan

  • pclaarpclaar Posts: 8Questions: 4Answers: 0

    Hi Allan,

    Oh yeah, that fixed it. Thanks so much for your quick response and fix!

    Pete

This discussion has been closed.