website load very slow when retrive data from firebase using datatable

website load very slow when retrive data from firebase using datatable

obskobsk Posts: 12Questions: 1Answers: 0

Hi guys, my app just had 337 items, i get from firebase. The downside is that it seems to be very slow when drawing the data. Why when i disconnect table.rows.add([dataSet]).draw(); works quickly.

The code is:

productos.orderByChild("articulo").on('child_added',function(datos){

var producto=datos.val();

dataSet=[datos.key,rellenar(producto.cantidad),producto.articulo,producto.descripcion,producto.pais,decimal,ubicacion];
datatableproducto.rows.add([dataSet]).draw();

});

Replies

  • allanallan Posts: 63,468Questions: 1Answers: 10,466 Site admin

    Thanks for your question. As noted in the forum rules, please post a link to a test case showing the issue so we can offer some help. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Allan

  • obskobsk Posts: 12Questions: 1Answers: 0

    Thanks for response allan, I have the right example here

    http://live.datatables.net/salajihu/23/

    I do not understand why here is faster than on my website, anyway it's still a little slow.

    is there any way to improve it?

    Thanks

  • allanallan Posts: 63,468Questions: 1Answers: 10,466 Site admin

    The problem is the draw() call inside the `child_added_ event handler. There are ~360 rows in the table, so it is being fully redrawn 360 times and that is really expansive. What you really want is to redraw it only once, after all of the rows have been added.

    Is there a way to know then all of the rows have be fed back from Firebase? If so, that's where I'd suggest putting the draw() call.

    Allan

This discussion has been closed.