Filtering the dataset to display results.

Hello Community,

I am new to WIX and this is my first time designing any website anywhere. I have done a bit of coding in my high school but did not pursue it further, I am currently trying to design a website on WIX and I am stuck with a few things.

So, my homepage has these two drop downs with different options, one has a list of CAUSES (animals, kids, education, LGBTQ rights) and the other has CITIES (Boston, New Delhi, New York) and a button below to proceed. I have already created a database where I am taking entries of events, and each entry has the CAUSE and CITY listed in it.


What I want is when the user selects his CAUSE and CITY and clicks on the BUTTON, he should be redirected to a page where all the events that match the CAUSE and CITY selected by the user, is filtered from the database and displayed on a REPEATER (image below).

Query 2: In the above REPEATER, once the user clicks “KNOW MORE”, a new page should open displaying extended details of the event. I have created a dynamic page and connected all the fields to the database, so my dynamic pages are working fine. My query is how to link those pages to the KNOW MORE button on each block of the REPEATER so that they open the dynamic page of the event clicked on?

I would be thankful if the community can help me solve these problem. Thanking all of you in advance, and looking forward to more exploration and developments in the WIX community.

Regards and Love,
Neelabh

Hey
First of all when someone selects the dropdowns and clicks your button you need to filter the repeater below using the setFilter method on the repeaters dataset. So place the repeater on the same page as the dropdowns if you want and just read about the setFilter in the API Reference under Resources on this page. You will find sample code to use.

The second question is easier, just click the button in the repeater on ITEM 1 and set the action to go to the dynamic page that the repater is connected to. Voilà.

If you need any more help, just ask. Good luck with your very good initiative

Hey Andreas,

First of all, thank you for replying and taking out time to help me. I did follow your suggestions and figured my way out to the following code:

import wixData from ‘wix-data’;

$w.onReady( function () {
$w(“#filter”).onClick(()=>{
$w(“#dataset1”).setFilter(wixData.filter()
.eq(“causeTag”, $w(“#dropdown1”).value)
.eq(“city”, $w(“#dropdown2”).value));
});
});

When I “PREVIEW” the above code, it works fine, the REPEATER displays the filtered data according to the CAUSE and CITY selected. But, the REPEATER remains blank on the PUBLISHED website. Can you help me with the same? I am a novice with WIX code, hence having a tough time in getting ahead.

Thanking you again for the help and I look forward to your suggestion.

Regards,
Neelabh

@neelabh99 Hey
This is probably because when you preview your site you are using the Sandbox Data Collection and if you do not SYNC your Data Collection from Sandbox → Live there is no data to display on the published site.

So go to Data Collection and hit the SYNC icon in the upper right corner and select Copy all items to Live and then you are good to go.

If you like my answer please mark my solution as Top Comment as it will help others to find the solution faster.

Happy coding.

@neelabh99 Hey
Take away your new questions from this thread and post them as new separate questions. It is impossible to find answers if the threads keep growing with new questions all the time. I will keep a look for your new questions. The smaller the posts are the faster you will get support and the greater the forum will be for all.

So please keep one question per post as a rule to get help faster.

So edit this and post the new ones as new posts.

@andreas-kviby Hey,

Apologies for defying the rules. Will keep that in mind from the next time.

Have created a new post: https://www.wix.com/code/home/forum/community-discussion/repeater-buttons-and-dynamic-pages

Looking forward to your suggestions and help.

@neelabh99 Assuming your repeater is displaying the correct event information then the simple answer is that you should be able to connect the Know More Button to the Dynamic Page you have created using the link option. There shouldn’t be a need to use Wix Code.


NOTE: Because the button on a repeater has the context of the item in a dataset when it is clicked it automatically sends the correct item from the data collection to the dynamic page.

Cheers
Steve