1

I am getting this error on line:

return filter ? value.filter(element => element.type.toLowerCase().indexOf(filter.toString().toLowerCase()) != -1) : value;

when element.type is an empty string (filtering empty column). How to fix this?

0

3 Answers 3

5

As the message states: element.type is undefined. Add a check on that in your filter call. Something like this, what you put depends on what you are expecting back and I can only guess at that.

return filter 
    ? value.filter(element => element.type && element.type.toLowerCase().indexOf(filter.toString().toLowerCase()) != -1) 
    : value;
Sign up to request clarification or add additional context in comments.

Comments

0

Well said, error itself gives the solution as the value passed to change into lowercase is null or undefined.

Just add to your line of code, where you see error coming

if(somevalue != null || somevalue != undefined)
{ ... }

Comments

0

This error itself gives the solution as the value passed to change into lowercase is null or undefined. To solve such errors, put the statements for the data to be passed in an if statement.

Like :

if(somevalue != null || somevalue != undefined)
{ ... }

Putting the statements inside if statement solved my issue.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.