canvas-datagrid icon indicating copy to clipboard operation
canvas-datagrid copied to clipboard

fitColumnToValues without value crash

Open AuHau opened this issue 5 years ago • 2 comments

Expected behavior and actual behavior.

When calling fitColumnToValues() without value, all columns should be refitted to data as described in documentation. Datagrid instead crashes on

Uncaught TypeError: Cannot read property 'index' of undefined
    at HTMLElement.e.fitColumnToValues (canvas-datagrid.js:1)
    at switchSheet ((index):242)

Upon checking source code, there is really no mechanism for fitting all columns: https://github.com/TonyGermaneri/canvas-datagrid/blob/master/lib/publicMethods.js#L602

Steps to reproduce the problem.

Call fitColumnToValues() without value

Specifications like the version of the project, operating system, or hardware.

Version: latest.

AuHau avatar Jan 25 '19 20:01 AuHau

oh no! That's terrible.

In the meantime you can use this:

grid.schema.forEach(function (c) { grid.fitColumnToValues(c.name); });

It will do the same thing.

I'll get this error patched up.

TonyGermaneri avatar Jan 25 '19 20:01 TonyGermaneri

Sweet, thanks! 👍

AuHau avatar Jan 25 '19 20:01 AuHau