Slow init or redraw on scrollX tables with lots of columns

Slow init or redraw on scrollX tables with lots of columns

osherososheros Posts: 4Questions: 2Answers: 0

Looking back through https://datatables.net/forums/discussion/64103/lower-the-initialization-time-for-long-scrollable-tables, one comment was that the initialization is slow because DT has to read and write the widths. Could this be avoided if the width was provided? If in columnDefs or columns, the width is provided, no calculation needs to be done, right?

I have a table with 290 columns and it takes about 45 seconds to draw the table. It's similarly sluggish when searching, presumably because DT nukes and repaints the whole thing with the filter applied. Would this get faster if I just provided the column widths? I wouldn't mind fixing them to specific widths and having per-cell overflow hidden or ellipsed.

Answers

  • kthorngrenkthorngren Posts: 21,328Questions: 26Answers: 4,949
    edited July 2023

    If in columnDefs or columns, the width is provided, no calculation needs to be done, right?

    Possibly autoWidth will help with the use of columns.width. A simple / quick test might be this init code snippet:

      autoWidth: false,
      columnDefs: [
        {
          targets: '_all',
          width: '100px',
        }
      ]
    

    For example:
    https://live.datatables.net/fawiyome/1/edit

    Not the table width is set to a specific value.

    Kevin

  • osherososheros Posts: 4Questions: 2Answers: 0

    Thanks. I do have the above in my code so I'll have to test more to see if I can figure out why it's sluggish to render.

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    This section of the FAQ should help, it discusses various techniques to improve performance.

    Colin

Sign In or Register to comment.