Slow row.add

Slow row.add

icynatorhdicynatorhd Posts: 2Questions: 0Answers: 0

Hey guys (and girls),

i have a issue with table.row.add because its very slow with ~90k rows. My code:

table.clear(); 
$.each(data, function (index, element) {
  var tablerow = table.row.add([element.ID, element.Nr, element.Datum, element.Zeit, element.Total, element.Punkte]).node();
  /*$(tablerow).attr('data-id', element.ID);*/
});
table.draw();

json string (value of the data variable):

[{"ID":"123456789","Nr":"123456789","Bla":"123","BlaBla":"321","Datum":"1111-11-11","Zeit":"11:11:11.0000000","Blub":"11","Total":"11,11","Punkte":"11"},
{"ID":"123456789","Nr":"123456789","Bla":"123","BlaBla":"321","Datum":"1111-11-11","Zeit":"11:11:11.0000000","Blub":"11","Total":"11,11","Punkte":"11"}]

Code works with a few (some hundred) lines. But when i have 90k rows to add the browser freeze and it takes very long ~10 minutes to come back.

Anyone ideas?

Best wishes,
Daniel

Replies

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    I wonder if it would be faster to use rows.add() and add all at once. If this improves the speed then maybe you could use columns.render to apply the data-id attribute.

    Another option would be to add the data during initialization using data. This combined with deferRender might help.

    Kevin

  • icynatorhdicynatorhd Posts: 2Questions: 0Answers: 0

    Works. Thx.
    But IE has some Problems with the size of the json string now. But i can fix it with some more requests to the db.

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    Not sure how you are retrieving the data now. But if you are using ajax you could implement Server Side Processing. That would mean that your server script is responsible for searching, sorting and returning only the rows to be displayed on the page.

    Otherwise you will need to work with the solution you currently have to limit the data.

    Kevin

This discussion has been closed.