Vue-good-table: Sorting is broken when cell data is undefined

Created on 8 Feb 2018  路  3Comments  路  Source: xaksis/vue-good-table

Hey,

thank you for this amazing package!

I get an error when a cell contains undefined data:

full backtrace:

TypeError: d is undefined
Stack trace:
cook@webpack-internal:///167:928:7
compare@webpack-internal:///167:931:9
processedRows/computedRows<@webpack-internal:///167:6531:18
mutator@webpack-internal:///1:829:18
processedRows@webpack-internal:///167:6519:24
get@webpack-internal:///1:3114:13
evaluate@webpack-internal:///1:3221:16
computedGetter@webpack-internal:///1:3473:9
paginated@webpack-internal:///167:6542:11
get@webpack-internal:///1:3114:13
evaluate@webpack-internal:///1:3221:16
computedGetter@webpack-internal:///1:3473:9
get@webpack-internal:///1:1919:7
render@webpack-internal:///167:14898:51
renderMixin/Vue.prototype._render@webpack-internal:///1:4473:15
updateComponent@webpack-internal:///1:2764:18
get@webpack-internal:///1:3114:13
run@webpack-internal:///1:3191:17
flushSchedulerQueue@webpack-internal:///1:2953:5
nextTick/<@webpack-internal:///1:1812:9
flushCallbacks@webpack-internal:///1:1733:5

I guess this error comes from:
https://github.com/xaksis/vue-good-table/blob/5f9eb92ef79297c5a40184c7b9266256920a531e/src/components/types/default.js#L15

Is there a workaround for this, like setting a default value to a null cell. Or is it a bug?

Cheers,

Jannis

bug

Most helpful comment

@jannishuebl You're very welcome! Thank you for bringing this up. looks like a bug, will take a look at it shortly. An interim workaround would be to replace undefined with empty text.

All 3 comments

@jannishuebl You're very welcome! Thank you for bringing this up. looks like a bug, will take a look at it shortly. An interim workaround would be to replace undefined with empty text.

@xaksis You can check an undefined value in your default compare function. There is a cook function that assumes that the value passed to it will be text. You can check it there and set the text to be an empty string.That will solve this issue

compare: function compare (x, y) {
function cook (d) {
return d.toLowerCase()
}
x = cook(x)
y = cook(y)
return (x < y ? -1 : (x > y ? 1 : 0))
}

@jannishuebl @bcrowe306 this should now be fixed in v1.19.3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jonathan-wondereur picture jonathan-wondereur  路  6Comments

mustfullDev picture mustfullDev  路  3Comments

davidohlin picture davidohlin  路  6Comments

tverilytt picture tverilytt  路  6Comments

Sharvadze picture Sharvadze  路  4Comments