Performance 1.9 vs 1.10 when manipulating all rows

Performance 1.9 vs 1.10 when manipulating all rows

bholubbholub Posts: 6Questions: 1Answers: 0

I have a table with a checkbox column. I have a toggle all checkboxes at the top to check/uncheck all at once. It's fast in 1.9 but slow in 1.10 so I'm guessing I'm doing it in a less than ideal way... any feedback would be greatly appreciated:

1.9 method:

var rows = reportingTable.$('tr', {filter: 'applied'});
rows.each(function(index) {
     if (target.is(':checked')) {
         reportingTable.fnUpdate(true,this,0,false,false);
    } else {
        reportingTable.fnUpdate(false,this,0,false,false);
    }
});

1.10 method:

var rows = reportingTable.rows({search: "applied"}).indexes().each(function(idx) {
    var d = reportingTable.row( idx ).data();
    d.checked = (target.is(":checked"));
 
    reportingTable.row( idx ).data( d );
});
reportingTable.draw();

Answers

  • bholubbholub Posts: 6Questions: 1Answers: 0
    edited August 2014

    EDIT: I thought I solved it below, but in reality that just grabs the visible rows. My table is paged, so this is not the solution. Still working on it, but if anyone has thoughts please let me know! Thanks!

    I was able to get much better performance going straight to the cells:

    var cells = $("td.datatable_checkbox_cell").each(function(index,el) { 
        var cell = reportingTable.cell(el);
        var d = cell.data();
        d.checked = checked;
        cell.data(d);
    });
    reportingTable.draw();
    
  • allanallan Posts: 63,514Questions: 1Answers: 10,472 Site admin

    You could try using the $() method:

    var cells = table.$('td.datatable_checkbox_cell')...
    

    Are you looking just to set the checked state of the checkboxes? How about:

    table.$('td.datatable_checkbox_cell input').prop( 'checked', checked );
    

    ?

    Allan

  • bholubbholub Posts: 6Questions: 1Answers: 0

    I'll try it and report back, but I believe I need to change the underlying data because I have buttons that act on the data (download selected rows to CSV). I think I tried just checking the boxes, which was fast, but it only selected the visible page.

This discussion has been closed.