Hey everybody, I created a database that is sorted with a drop-down. I was wondering if there was a way to have a 'select all' in the drop down menu because once someone sorts by a feature, they cannot unsort it.
For example, this database is for actors and once someone sorts by hair color, they have to select a hair color and cannot just go back and unsort by hair color and sort by just eye color instead. I currently have a neutral option where the value is set by a common aspect to all the features, such as a letter they all share, but as I'm adding more options that is getting complicated.
Any ideas would be appreciated! Love this forum!
Hi Nelson,
you can do that but why separating it into 2 different pages?
Shlomi
Awesome work here from all of you! This is very helpful. Thanks for sharing this in so much detail.
Quick question... I am setting up a similar page (more like the airline example above with the tick boxes) except I would like for user to be to be able to select from categories displayed on landing page which will then direct them to the filtered results page (event listings) with the specific filter results displaying based on the category they chose on the previous page. I havent started on the results/event listings page as of yet until I find the best method, so that I don't waste time going back and forth.
Any feedback is greatly appreciated!
- Nelson
I LIKE THIS! :-) Can I use the code for selecting parts according to one or more selections in drop menus?
I'd like my visitors to be able to find car parts depending on their selections of :
- year
- and/or make
- and/or model
- and/or part name
Here's my site to help you understand :
merlinregis.wixsite.com/accueil
Shlomi,
I think I figured it out! Thank you!
Hi Shlomi,
I'm sorry, I'm really new to coding. What would I code in to reveal a hidden element?
Emma
Hi Team Wix Code, I deployed a code which I copied from Wix Expert Nayeli but I modified it a bit to use a drop-down instead of a search input box.
My question is, how can I link the items in the display box to the database collection? Here's the code which I used:
import wixData from 'wix-data';
$w.onReady(function () {
//TODO: import wixData from 'wix-data';
});
export function dropdown1_change() {
wixData.query('Matching-Category')
.contains('category', $w('#dropdown1').value)
.find()
.then(res => {
$w('#table1').rows = res.items;
$w ('#table1').show();
});
}
Here's the reference screenshots:
Emma,
Indeed, the code gets you to a point where no result is found, in which you can code anything you want. I'd go for displaying a text that says that, and hiding it in case there are results, but your choice, just cide it right there :)
Shlomi
Hi Shlomi,
I looked at the code and see that the code you gave me displays 'no results found' in the developer's console. Is there a way to have the code set so it displays text or an image on the screen for the viewer when no results are found? I can even make an entry to the database that is displayed when no results are found that is a picture that says 'no results found'.
Thanks for all your help!
Emma
Hi andre,
Dynamic data set is just a name, the Id emma decided to call her dataset thats all :)
Shlomi
Hi Shlomi,
I'm getting sooo frustrated with this.. i'm still struggling to make it work.
How do I add a dynamicdataset to a regular page to start with? I can only add a Dataset.
Hi Shomi,
Thank you! It's thanks to your help :)
I put the code in at the bottom of my code and it's not working. I tried changing it to have a vector object appear that I had collapsed/hidden on load. Any ideas on how to fix this? I don't need to show a vector object, just something to let the viewer know that there are no results.
Thanks again for all of your help
Emma
Thank you very much for the swift reply Shlomi. I'll try it out and as soon as possible I'll tell you the result.
Andrea,
the following code should do the trick, also add a button to trigger the event
function filter(title,$w) { console.log(title); $w("#dynamicDataset").setFilter(wixData.filter().contains("title",title)); } export function button3_click(event, $w) { filter($w("#input1").value,$w); }
Shlomi
Hi Andre,
this thread is exactly about filtering of a repeater, it should not be done in a dynamic page. you can add a button or picture to each of the repeater items which will redirect to a dynamic page for that specific item. the entire collection can be done in a normal (non-dynamic) page
Shlomi
Hi Shlomi,
This might be a tall order but could you share the steps and the code to filter the content of a repeater that is synced to a database?
I've already read all articles of the forum and watched the tutorials including this one https://www.youtube.com/watch?v=Hx7_8-lRsW0&index=32&list=PL0y_aclKYoYhBjCHf1hbj-I7sti3uC9rb, but I can't make it work...
To start with, should this be made on a dynamic page or a regular one?
This is my page: https://andregfsnunes.wixsite.com/meusite/PersonalTrainers
And this is my code:
-----------------------------------------------------------------------------------------------------
import wixData from "wix-data";
$w.onReady(function () {
//TODO: write your page related code here...
});
export function input1_keyPress(event, $w) {
filter($w("#input1").value);
}
function filter(title) {
$w("#dynamicDataset").setFilter(wixData.filter().contains("articleTitle",title))
}
-----------------------------------------------------------------------------------------------------
I'd really appreciate your help.
Hi Emma,
looks really great! well done!
in the last section, alter the code and implement anything you'd like, like showing a text if there are no results and hiding it if there are
$w('#dataset1').setFilter(filter).then(function() { let count = $w("#dataset1").getTotalCount(); if(count===0){ console.log("No results found"); } });
Shlomi
Hey Shlomi,
Thank you so much for your help! Here's a link to the website if you want to look at it: https://www.emmalparker.com/michigan-talent-database
I was wondering if there's a way to code a 'no items match your search query'?
Thank you!
Emma
Shlomi,
Thank you! I will look into a redesign and let you know what I need. Either way, I really appreciate all the help you have already given me!
Emma
Hi Emma,
The example with the 'G' above will let be select all fir the dropdown, meaning wont filter by this criteria, so we can make that work.
It is just a matter of multiple select or not, your call :)
I'd anyway recommend you redesign the page to make it less clutter, maybe even enable hide/show of filters upon user click.
If you'll still need help with checkboxes and dropdowns mixed, please let me know, ill be able to help you out with the code tomorrow,
Shlomi
Shlomi,
I feel it is more user friendly to have checkboxes for the build and drop-downs for other search options. I considered having all checkboxes, but this makes the search too cluttered looking for the user. Also there is no 'select all' option for the dropdowns, which makes it impossible to change up a search without refreshing the whole window.
Thanks!