Speed up drawing time

Speed up drawing time

birobiro Posts: 12Questions: 7Answers: 0

Hi! I'm working with datatables, and a huge amout of data.
I was wondering how to speed up the drawing time.
i got paging set to true (25 rows per page), but if i resize the window, it takes up to 5-6 seconds to fit the width.
is the something that i miss?!

thank you

This question has an accepted answers - jump to answer

Answers

  • pavlompavlom Posts: 8Questions: 2Answers: 0

    Hi

    Not clear what you do exactly. Do you resize your browser window with 25 rows data DataTable? How many columns you have.

    In my table with 25-50 rows 10 columns, browser window resize takes less than second.

  • birobiro Posts: 12Questions: 7Answers: 0

    sorry, maybe i'm not clear ;)
    my table has 15k row and 20 columns.
    the datatable is rendered in my browser window (actually an electron/nodejs project)
    so it very common to resize the window.

    i think that the amoun of data, slows down the draw() function...it takes 5-6 seconds to redraw the table correctly
    here's the code that i use to manage the resize:

    $().ready(function() {
        $(window).on('resize', function() {
          $('#dataTable').DataTable().columns.adjust().draw();
        })
    })
    
  • allanallan Posts: 63,225Questions: 1Answers: 10,416 Site admin
    Answer ✓

    You should be able to remove that code and just have width="100%" on the table element. DataTables will automatically do the resize for you and it will also throttle it so it doesn't kill your browser.

    Allan

  • birobiro Posts: 12Questions: 7Answers: 0

    it works! thanks allan!
    i feel so dumb right now :p

  • allanallan Posts: 63,225Questions: 1Answers: 10,416 Site admin

    Its not that obvious really! Reading a precentage value from CSS is a massive PITA which is why that is required. It lets DataTables know that you want it to be 100% width and it can run some code to keep it that way.

    Allan

This discussion has been closed.