Table with multiple dataset filtering

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.

Make sure that you are using the field key and not the field name.


Not this: Tournament
But this: tournament

Yisrael,

Thank you the reply. That is a very good point and I have corrected this, however it is still not working. Any other suggestions?

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 At first I was trying to use Location (not the same as TxID), but then switched to TxID and it is still not loading

@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 Please post the editor URL of your site so we can inspect. Only authorized Wix personnel can get access to your site in the editor.

@yisrael-wix https://editor.wix.com/html/editor/web/renderer/edit/3ec0c417-366f-4edc-bfeb-957a932a55c8?metaSiteId=308a04ab-a1b4-4720-aa59-9af494bab78b&editorSessionId=eda325c8-4ea0-4413-938a-5cb9c47b164a&referralInfo=my-account

Thanks. It’s the static page labeled RESULTS

@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.

I tried this and it seems to work for me.

Good luck,

Yisrael

@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.

1 Like

@yisrael-wix Than you, that worked great!

1 Like

how we can set multiple filters on single export function input_change(event)

Please post a new forum post and refer back to this with a link instead of bumping up an old thread from 2018.

Closed.