Can't filter a dataset

I am trying to link up a dropdown with a dataset so I can create a search filter.

I tried:

  1. Using the built in dataset linking options but that causes my dropdown to be disabled. Enabling it in HTML still does not make it work.
  2. Using a change event to trigger the dataset filtering logic I wrote below. Filtering by any location returns 0 results even tho the property exists and has multiple entries for each location.
import wixData from "wix-data";

$w.onReady(() => {
});

export function filter(event, $w) {
	$w('#villaDataset').setFilter(
		wixData.filter()
		.eq('Location', $w('#locationFilter').value)
	);
}

What am I doing wrong?

Hi Igor,

Connecting a dropdown to a dataset can be done from the editor (no code required).

Is the dropdown also hidden when it is not connected to a dataset?

Idan.

Hey Idan,
I am aware that it is possible but as soon as I link it’s value to the dataset the dropdown stays in it’s “disabled” state and I can not do any changes to it.

Still nothing, here is everything I did. I feel like I am going mad. I am either missing some crucial detail or this is a bug in the platform:

  1. Created a dropdown with all Locations.
  2. Added this code to the page to be triggered when the filter button is pressed.
import wixData from "wix-data";

$w.onReady(() => {
});

export function filter(event, $w) {
	var newFilter = wixData.filter()
		.eq('Location', $w('#locationFilter').value);
	$w('#villaDataset').setFilter(newFilter);
}
  1. When i select the location in the dropdown and click filter the client sends this request to the server.


4. For some reason this returns 0 results and therefore removes all items from my repeater. This should not happen since my table indeed has entries for this location.


Now, where is the flaw in my logic here? I just can’t seem to find it myself…

Found the issue by doing some more debugging. This is horrible UX tho and should be noted somewhere. The filter function expects the column key, not it’s name. In the wix-data reference it is even called “propertyName” and not “propertyKey”.