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

Allow filtering of data when some keyed columns contain null #2

Merged
merged 3 commits into from
Aug 19, 2016

Conversation

PhilipRieck
Copy link
Contributor

If you have a collection where some of the objects have a property that resolves to null, and you set the filter-keys to contain that property, the doFilter method would stop with an error trying to call toString() on the null value.

if (value.toLowerCase().indexOf(this.filterText.toLowerCase()) > -1) {
filteredData.push(next);
break;
if( next[key]){
Copy link
Owner

@tochoromero tochoromero Aug 19, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the property in question has a value of 0, it will evaluate to false.

We need to check if next[key] != null && next[key] != undefined

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great point, although next[key] != null also checks for undefined due to coercion. I'll fix this in the pull request.

@tochoromero
Copy link
Owner

Thank you for sending the pull request, I added a small note.
Also, for some reason your build is adding one extra space in one of the pagination files, I guess you can omit those from the commit.

@PhilipRieck
Copy link
Contributor Author

I reverted the whitespace change on the build (sorry!). Great catch on 0 values being ommited, I've fixed that as well.
Great simple component by the way - love it.

@tochoromero tochoromero merged commit 18a73c6 into tochoromero:master Aug 19, 2016
@tochoromero
Copy link
Owner

I have merged your pull request. Thank you for the fix :)

I'm glad you like the table, this is my very first open source contribution, please don't hesitate to send any comments or suggestions.

@PhilipRieck PhilipRieck deleted the nullfix branch August 27, 2016 16:38
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

Successfully merging this pull request may close these issues.

2 participants