Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'string' of undefined #204

Open
Michelgard opened this issue Jan 3, 2020 · 1 comment
Open

Cannot read property 'string' of undefined #204

Michelgard opened this issue Jan 3, 2020 · 1 comment

Comments

@Michelgard
Copy link

I have this error when I click on the column to sort:
stupidtable.min.js: 3 Uncaught TypeError: Cannot read property 'string' of undefined
     at k.fn.init.c.fn.stupidsort (stupidtable.min.js: 3)
     at HTMLTableCellElement. (stupidtable.min.js: 1)
     at HTMLDivElement.dispatch (jquery-3.4.1.min.js: 2)
     at HTMLDivElement.v.handle (jquery-3.4.1.min.js: 2)

@brianfreud
Copy link

I had the same error popping up. It seems to be coming from
var diff = sort_info.compare_fn(e1.columns[th_index], e2.columns[th_index]);
when either e1[index] or e2[index] doesn't exist.

In my particular case, it stemmed from a table that had a 'short' row. Ie:

H1 H2 H3
A1 B1 C1
A2 B2
A3 B3 C3
A4 B4 C4

Note the missing cell C2. Sorting on H3, it'd try to read the string from the nonexistant C2, making the sort function fail due to an undefined string as argument e1[index].

Normally, this likely indicates an issue with the table, not the sort. However, the sort should be able to handle this; I'd suggest that var diff needs to first check that both e1[index] and e2[index] actually exist before trying to sort them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants