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

match is not a function #412

Open
lcborn4 opened this issue Jan 20, 2017 · 8 comments
Open

match is not a function #412

lcborn4 opened this issue Jan 20, 2017 · 8 comments

Comments

@lcborn4
Copy link

lcborn4 commented Jan 20, 2017

item[column.name].match is not a function

Has anybody gotten this error before?

return item[column.name].match(column.filtering.filterString);

is .match are javascript function?

@lcborn4
Copy link
Author

lcborn4 commented Jan 20, 2017

So im not sure why match function wasn't found but i found a workaround by using ==

return (item[column.name] === column.filtering.filterString);

@webcat12345
Copy link

string.match() is javascript function.
parameter is regex.

you will get that error, when null.match. so You need to convert all undefined or null to ''(emptyString).

Additionally regex syntax will now allow |\/[](). You need to make new function for this case.

@pranee1h
Copy link

pranee1h commented Feb 15, 2017

Can I know the function??

@pranee1h
Copy link

I am trying to fix by adding if conditionif (column.filtering) { filteredData = filteredData.filter((item:any) => { if(item[column.name] === null){ item[column.name] = ""; } return item[column.name].match(column.filtering.filterString); }); } but it's not working. Can someone post the solution??

@pranee1h
Copy link

With this return (item[column.name] === column.filtering.filterString); search is not working

@noagr1
Copy link

noagr1 commented Feb 20, 2017

another if helped me:

if (item[column.name]){
            if (item[column.name].toString().match(this.config.filtering.filterString)) {
            flag = true;
            }
        }

@webcat12345
Copy link

webcat12345 commented Mar 28, 2017

data shouldn't contain nullstring. This is the first case.

Before drawing table you need to convert null to ''(empty string).
Second is regex.

convertSpecialCharacter(str:string):string {
    const regex = /\/|\\|\(|\)|\[|\]|\|/g;
    let m;
    while ((m = regex.exec(str)) !== null) {
      if (m.index === regex.lastIndex) {
        regex.lastIndex++;
      }
      str = str.substr(0, m.index) + '\\' + str.substr(m.index);
      regex.lastIndex++;
    }
    return str;
  }
return item[column.name].toLowerCase().match(this.publicService.convertSpecialCharacter(column.filtering.filterString).toLowerCase());

@niskah-energies
Copy link

I have the same error, but don't know why. filterString is not undefined, it's an empty string but item[column.name] is an integer, maybe it's the problem

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

No branches or pull requests

5 participants