Filter issues

Hi everyone,

I have a textbox (iSearch) and drop down (iCategories) I would like to use to filter the results of a query. My code is as follows. However, everytime I click the drop down, It gives me an error. I need it essentially to search if it contains the item the user enters in the iSearch or iCategories objects. .includes() was not working so I tried the search technique. Thanks.

Also, could someone guide me as to what the text after !== should be? Thanks.

let oldRows = [];
$w.onReady(() => {
oldRows = $w(“#table1”).rows;
});

function filterTable() {
let newRows = oldRows.slice();
const search = $w(‘#iSearch’).value;
const categories = $w(‘#iCategories’).value;

if(search && search !== ‘Search Opportunities’) {
newRows = newRows.filter(item => item.search.search(search) > -1);
}
if(categories && categories !== ‘’) {
newRows = newRows.filter(item => item.categories.search(categories) > -1);
}
$w(“#table1”).rows = newRows;
}

export function iSearch_keyPress(event) {
filterTable();
}

export function iCategories_change(event) {
filterTable();
}

Thank you for anyone’s help!

Hi Alexander!

Please share a link to the page that you are facing issues with.
Please try and elaborate on what is it that you want to achieve.
Do you want the results of the iSearch to be filtered by the choice from the iCategories?

Doron.