Skip to content

Autotable blocks the UI with large amount of data #1017

Description

@zs-err

This is my code:

  exportAsPdf(tableName: string, columns: any, exportData: any, minimal?: boolean) {
    const doc = new jsPDF('l', 'mm', [minimal ? 600 : 297, 210]);

    const columnStyles = {};
    columns.forEach(column => {
      column.dataKey = column.field;
      columnStyles[column.dataKey] = { minCellWidth: 20 };
    });

    autoTable(doc, {
      columns,
      body: exportData,
      theme: 'grid',
      columnStyles
    });
    doc.save(tableName + '_' + new Date().getTime() + '.pdf');
    this.globalService.addFileToExportQueue('remove', tableName);
  }

Versions

    "@angular/core": "^14.2.0",
    "jspdf": "^2.3.1",
    "jspdf-autotable": "^3.5.14",

So when i have a lot of data, the autoTable function just blocks my main thread and my app freezes. This is a use case for us and we need some way to handle it.

Web workers are not an easy option for us because of this:
microsoft/TypeScript#20595 (comment)

Is there any way to make the job be async or chunkable? I need a way for it not to freeze the whole app.

Thank you

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions