Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery.dataTables very slow in ie 11

A user has reported a strange problem, where after upgrading to ie 11, jquery.dataTables are very slow (20 - 40 seconds) to render. There are approximately 400 results, which seems resonable. And it runs VERY quickly in Chrome and FF.

After doing some diving, it turns out that any call to table sorter is causing server slowness.

We're using 1.9.4, although attempts at upgrading to 1.10 have not shown any performance improvements either.

The code is very straightforward:

$('#results_table').dataTable({
        "aoColumnDefs": [
            { "bSortable": false, "aTargets": [ 0, 1, 12 ] },
            { 'sType': 'currency', 'aTargets': [8] }
        ],
        "aaSorting": [[19, 'asc'], [18, 'asc'], [16, 'desc'], [4, 'desc'], [13, 'desc'], [5, 'desc'], [14, 'desc'], [15, 'desc'], [3, 'asc'], [6, 'desc']]
    });

Any thoughts on improvements would would welcome.

like image 424
earnold Avatar asked Jul 14 '14 20:07

earnold


1 Answers

This isn't exactly a fix, but it is a good work around. I switched to building an array of data and attaching that to dataTables instead of building dom elements.

Example:

$('#results_table').dataTable({
  "aaData":[[attrs], [attrs]], // an array of row data
   "aaSorting": [[19, 'asc'], [18, 'asc']],
   "aoColumns": [
       { "sClass": "center" },
       //... other class definitions
    ]
});
like image 81
earnold Avatar answered Nov 15 '22 15:11

earnold