I'm having trouble searching for the first name, middle name, and last name together. Currently, I can only search for each separately.
For example: When I try to search for "Jacob jj9eqwif Nguyen", it doesn't work. But if I search for Jacob, it works. If I search for jj9eqif, it works. If I search for Nguyen, it works.
Please check out this LINK for more information.
search(event) {
const val = event.target.value.toLowerCase();
if (!val) {
this.data = this.tempData;
}
const temp = this.tempData.filter(row => {
return Object.keys(row).some(property => {
if (property === 'received_by') {
return row[property].fname
.toString()
.toLowerCase()
.indexOf(val) !== -1
? row[property].fname
.toString()
.toLowerCase()
.indexOf(val) !== -1
: row[property].mname
.toString()
.toLowerCase()
.indexOf(val) !== -1
? row[property].mname
.toString()
.toLowerCase()
.indexOf(val) !== -1
: row[property].lname
.toString()
.toLowerCase()
.indexOf(val) !== -1
? row[property].lname
.toString()
.toLowerCase()
.indexOf(val) !== -1
: (row[property].fname + row[property].lname + row[property].mname)
.toString()
.toLowerCase()
.indexOf(val) !== -1;
}
if (property === 'warehouse') {
return (
row[property].name
.toString()
.toLowerCase()
.indexOf(val) !== -1
);
} else {
return row[property] === null
? null
: row[property]
.toString()
.toLowerCase()
.indexOf(val) !== -1;
}
});
});
this.data = temp;
}