alfajango / jquery-dynatable

A more-fun, semantic, alternative to datatables
http://www.dynatable.com
Other
2.77k stars 363 forks source link

Cannot read property 'toLowerCase' of null when sorting. #241

Open FraserChapman opened 8 years ago

FraserChapman commented 8 years ago

When a column contains a null value the error is thrown when that column is sorted.

// Built-in sort functions
// (the most common use-cases I could think of)

aAttr = aAttr.toLowerCase();

jquery.dynatable.js:923 Uncaught TypeError: Cannot read property 'toLowerCase' of null

lisrec commented 8 years ago

Hi, I had similarly problem. I had in column strings, and next after added number i got error "bAttr.toLowerCase(); is not a function".

I made little change in code (line 912 and 913):

aAttr = aAttr.toLowerCase(); bAttr = bAttr.toLowerCase();

change to this:

aAttr = aAttr.toString().toLowerCase(); bAttr = bAttr.toString().toLowerCase();

lisrec commented 8 years ago

About your problem, add before 912 line: if(typeof aAttr == 'undefined') aAttr = ""; else if(aAttr == null) aAttr = "";