I have 3 collections: Members, Tournaments, TxResults
TxResults contains a reference field named Tournament mapped to the TxID field that is in the Tournaments collection as well as a reference field called Member for the field Member Name in Members.
I have added a table to the page connected to the TxResults dataset, then created a dropdown connected to the Tournaments dataset to display a field called Location. Location is NOT a reference field in TxResults, but the TxID is.
What I would like to have happen is when the Location is selected (because it is more human-readable than the TxID) from the dropdown, the table is filtered to display TxResults for only that TxID.
Right now, the options in the dropdown is populating correctly, but when I select a Location, the table refreshes and there are no results.
This is what I have in my dropdown event:
export function Txdropdown_change(event)
{
$w(“#Txdataset”).setFilter(wixData.filter().contains(“Tournament”, $w(“#Txdropdown”).value));
}
Does anyone know if what I would like to do is possible?
I have tried following all of the Wix tutorials on YouTube regarding datasets and I also followed the one from Code Queen with using multiple dropdowns but that is not quite what I need.
What’s in the dropdown? If you are trying to filter based on the TxID, then each entry in the dropdown needs to have the value set to the correct TxID. You are doing a filter on the Tournament (key: tournament) field. Is that the same as TxID?
@yisrael-wix The field tournament in TxResults collection is a reference field mapping to txid in Tournaments collection. Would that cause an issue if I was trying to filter on tournament ?
So it looks like my data is disappearing from the table when using a referenced dataset filter. Following CMS: About Displaying Content from Multiple Database Collections Using Reference Fields | Help Center | Wix.com, I had a filter on my primary dataset for the TxResults collection for Tournament same as Tournaments dataset (connected to the Tournaments collection). Once I did that, no filters worked. Am I doing something wrong with this?
@poolshark314 You have the BoaterTxdataset dataset filtered like this:
This is perfect. Since one of the filters is Tournament same as current item from Tournaments dataset , all you need to do is to filter the Tournaments dataset ( Txdataset ) like this:
let txvalue = $w('#Txdropdown').value;
$w('#Txdataset').setFilter(wixData.filter().eq("title", txvalue));
Get rid of the other filters as the filtering is done using the Txdataset.
@yisrael-wix Yes that worked! But I did notice there is a different problem. After the dropdown is selected and the tables refresh, the dropdown is then locked to your selection. When you click the dropdown, no other options populate. Any thoughts on why this is happening? Thank you very much for your help!
@poolshark314 The problem is that after setting a filter on the Txdataset it will only have the filtered item - and that’s what’s being used to populate the dropdown.
To solve your problem, you need two datasets connected to the Tournaments dataset (Txdataset). One that is not filtered and is used to populate the dropdown, and the existing dataset that is filtered by the dropdown value, which is then used to filter the results.