I have implemented a filtering pipe logic for grid search.
results.filter(item => Object.keys(item)
.some(key => searchTerm.split(',').some(arg =>item[key]? item[key].toString().toLowerCase().includes(arg.toString().toLowerCase()):""))
);
The code above searches for a keyword in all columns in the array list, which is bound to the grid. However, I only want to search through the columns that are displayed in the grid.
So, the revised logic will be as follows:
results
.filter(item => (item.ProxyName.toLowerCase().includes(searchTerm.toLowerCase()) ||
item.ProxyType.toLowerCase().includes(searchTerm.toLowerCase())||
item.SA_SPOC_DL.toLowerCase().includes(searchTerm.toLowerCase())||
item.AssignmentGroup.toLowerCase().includes(searchTerm.toLowerCase()))
);
.filter(item => Object.keys(item)
.some(key => searchTerm.split(',').some(arg =>item[key]? item[key].toString().toLowerCase().includes(arg.toString().toLowerCase()):""))
);
To enable this, I decided to pass a comma-separated array of columns to filter like so:
string searchcolumns = ["ProxyName,ProxyType,SA_SPOC_DL"]
If I pass a comma-separated array of columns, how should I rewrite the logic?