Filter on table

hello Forum,

I am new to Wix and trying to build a website with some slightly “advanced” features. I couldn’t get the filter function on a table work, where I need some help.

the website is located at https://stephenxj5.wixsite.com/yyeducation/school-search

the code i am using now (not working) is as follows.

import {wixData} from ‘wix-data’;

export function button1_onclick (){
console.log(“apply fitlering”);
$w(“#dataset1”).setFilter(wixData.filter()
.contains(‘gend1618’,$w(‘#dropdown1’).value)
)
. catch ((error)=>{
let errorMsg = error.messsage
let code = error.code
});

Hi Stephen,

This is what shows in the browser console as the page loads:


What this means is that your function is missing a closing brace. You should be getting warned about this in the Corvid page editor with a red dot like the following:

Thanks, still couldn’t make it work, then I turned to try something simpler.

do you mind have another look?

the website is located at https://stephenxj5.wixsite.com/yyeducation/school-search

import wixData from ‘wix-data’;

$w.onReady( function () {

});

export function Dropdown1_change() {
let searchBrand = $w(“#dropdown1”).value;
$w(“#dataset1”).setFilter(wixData.filter().contains(“gend1618”, searchBrand));
}

Stephen, I had a look and see that it doesn’t filter, but I’m not understanding what you are trying to filter on. Your query is still filtering on gender, but your dropdown list items don’t suggest that you intend to do that.

@tony-brunsman Apologies, I forgot to publish after the changes were made. Could you help have another look? Appreciate your help.

@stephenxj Since the filter is not taking effect, it could be one of several reasons but the following is likely it.

Select Dropdown1. Make sure that the export function is listed next to onChange in the property sheet, and again check to see that it’s in the right case. If I add a dropdown and then the onChange event, Corvid names it with all lower case: dropdown1_change(). I’m noticing that your function name has the first letter capitalized even though your reference to the dropdown inside the function has it in all lower case, the name Corvid would give it.

@tony-brunsman It’s working now, thank you again for your help.