RobertoPrevato / KingTable

Library for administrative tables that are able to build themselves, on the basis of the input data.
MIT License
68 stars 17 forks source link

TypeError: Cannot read property 'length' of null #1

Closed Jopoleon closed 7 years ago

Jopoleon commented 7 years ago

Hello! I caught error when used KingTable with data of following format: All data : [Object, Object, Object, Object…] Object: Object CampaignID:13572830 ClicksContext:0 ClicksSearch:0 GoalConversionContext:0 GoalConversionSearch:0 GoalCostContext:0 GoalCostSearch:0 SessionDepthContext:0 SessionDepthSearch:0 ShowsContext:0 ShowsSearch:1 StatDate:"2015-10-11" SumContext:0 SumSearch:0 proto:Object

The error:

Uncaught (in promise) TypeError: Cannot read property 'length' of null
    at s (http://localhost:3000/static/js/libs/kingtable.js:66:33)
    at Object.compareStrings (http://localhost:3000/static/js/libs/kingtable.js:131:14)
    at http://localhost:3000/static/js/libs/kingtable.js:173:33
    at Array.sort (native)
    at Object.sortBy (http://localhost:3000/static/js/libs/kingtable.js:154:14)
    at t.value (http://localhost:3000/static/js/libs/kingtable.js:4049:41)
    at t.value (http://localhost:3000/static/js/libs/kingtable.js:4023:13)
    at t.value (http://localhost:3000/static/js/libs/kingtable.js:4716:17)
    at t.value (http://localhost:3000/static/js/libs/kingtable.js:4653:31)
    at t.value (http://localhost:3000/static/js/libs/kingtable.js:4635:49)
s @ kingtable.js:66
compareStrings @ kingtable.js:131
(anonymous) @ kingtable.js:173
sortBy @ kingtable.js:154
value @ kingtable.js:4049
value @ kingtable.js:4023
value @ kingtable.js:4716
value @ kingtable.js:4653
value @ kingtable.js:4635
value @ kingtable.js:3842
i @ kingtable.js:3775
a @ kingtable.js:3779
(anonymous) @ kingtable.js:3797
value @ kingtable.js:3773
value @ kingtable.js:5086
u @ kingtable.js:2034

Can somebody help me with that?

RobertoPrevato commented 7 years ago

Hi @Jopoleon, I will look into this as soon as possible, later today.

RobertoPrevato commented 7 years ago

@Jopoleon, I just did a push to fix the error, please download again the library and close this issue if the problem is resolved. kingtable.js here in GitHub. I am publishing the library in these days and still fixing some things.

Jopoleon commented 7 years ago

Hello, Roberto. I tried to fix it too today, and I found out, that error happens in line 66 in kingtable.js file. This line is some weird regex if condition. I just commented it with // and everything worked just fine . Thanks for answer. пятница, 05 мая 2017г., 23:28 +03:00 от Roberto Prevato notifications@github.com :

@Jopoleon , I just did a push to fix the error. Thanks for taking the time to open the issue. I am publishing the library in these days and still fixing some things. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub , or mute the thread .

RobertoPrevato commented 7 years ago

Great! :) that regular expression is used to highlight matches from text search. Code is weird because I need to escape HTML fragments, around portions of HTML that allow to obtain the highlighting.

For example:

// looking for "smo",

// string "Smokowski" is converted to:
<span class="kt-search-highlight">Smo</span>kowski

Please update the library anyway, since I corrected also other things related to the same issue.

RobertoPrevato commented 7 years ago

Closing, as the problem was resolved. Null values were causing problems in automatic sorting of strings that can be sorted by their numeric part (for example "100%", "50.20 EUR", etc.).