top of page

Forum Posts

Jim Sizemore
Apr 22, 2020
In Coding with Velo
Hello, I have attempted to use a set of 3 dropdowns to allow users to filter my collection first by Gas then by Connection with the results on the third dropdown. I have managed to get the Gas and Connection fields to load in dropdowns without duplicates which is great but the third dropdown is not populating. Ideally, I'd like to have the results populate the third dropdown and then, upon selection by user, the final result to populate in the table below the dropdowns (or elsewhere if there is a better way to display end result other than dedicated page. Thank you very much! // For full API documentation, including code examples, visit https://wix.to/94BuAAs import wixData from 'wix-data'; $w.onReady(function () { uniqueDropDown1(); }); function uniqueDropDown1() { wixData.query("chromeflowmeters") .limit(1000) .find() .then(results => { const uniqueTitles = getUniqueTitles(results.items); $w("#dropdown1").options = buildOptions(uniqueTitles); }); function getUniqueTitles(items) { const titlesOnly = items.map(item => item.gas); return [...new Set(titlesOnly)]; } function buildOptions(uniqueList) { return uniqueList.map(curr => { return { label: curr, value: curr }; }); } } export function dropdown1_change(event, $w) { uniqueDropDown2(); $w("#dropdown2").enable(); } function uniqueDropDown2() { wixData.query("chromeflowmeters") .contains("connection", $w("#dropdown2").value) .limit(1000) .find() .then(results => { const uniqueTitles = getUniqueTitles(results.items); $w("#dropdown2").options = buildOptions(uniqueTitles); }); function getUniqueTitles(items) { const titlesOnly = items.map(item => item.connection); return [...new Set(titlesOnly)]; } function buildOptions(uniqueList) { return uniqueList.map(curr => { return { label: curr, value: curr }; }); } } export function dropdown2_change(event, $w) { uniqueDropDown3(); $w("#dropdown3").enable(); } function uniqueDropDown3() { wixData.query("chromeflowmeters") .contains("title", $w("#dropdown2").value) .limit(1000) .find() .then(results => { const uniqueTitles = getUniqueTitles(results.items); $w("#dropdown3").options = buildOptions(uniqueTitles); }); function getUniqueTitles(items) { const titlesOnly = items.map(item => item.title); return [...new Set(titlesOnly)]; } function buildOptions(uniqueList) { return uniqueList.map(curr => { return { label: curr, value: curr }; }); } }
Conditional filtering of dropdowns content media
0
0
275
Jim Sizemore
Apr 21, 2020
In Coding with Velo
Has this topic been answered anywhere? I have been struggling with this issue. Trying to filter a collection using multiple fields / columns and display the results in the table. Either a dropdown where users can select a value from the Flow Range field (this field has duplicate values so I would need to eliminate repeated values. i.e., 15 lpm, 25 lpm, 15 lpm, 5 lpm, 25 lpm), a value from the Gas field (also duplicate values i.e., Air, Oxygen, Air, Oxygen) and a value from the Connection field (also duplicate values i.e., Chemetron, Ohmeda, Chemetron, Oxequip, Ohmeda). If a search input box and button are used the search would need to be for any of the terms entered in box. What I have been able to do only returns results in the table that have all of the terms exactly as entered so not much use currently. Any help would be greatly appreciated. Thanks! // For full API documentation, including code examples, visit http://wix.to/94BuAAs import wixData from 'wix-data'; export function button24_click(event) { const filterValue = $w("#input1").value const byTitle = wixData.filter().contains("title", filterValue) const byProductDescription = wixData.filter().contains("productDescription", filterValue) $w("#dataset1").setFilter(byTitle.or(byProductDescription)) //Add your code for this event here: }
0
4
64
Jim Sizemore
Apr 14, 2020
In Coding with Velo
Hello forum, Can anyone give me some guidance on how I can rectify my code error? I have a database connected to a table via dataset. I added a user input box and a button labeled Filter to allow users to search the table by description and created an onclick event for the button. This seems to work fine. But I want the user to be able to search more than just that one column. Here is the code I tried. import wixData from 'wix-data'; // For full API documentation, including code examples, visit http://wix.to/94BuAAs $w.onReady(function () { //TODO: write your page related code here... }); export function Filter(event) {$w("#dataset1").setFilter(wixData.filter() .contains("productDescription" , $w("#filterInput").value)) .contains("title" , $w("#filterInput").value); //Add your code for this event here: } I get no red dot by the code however users still cannot search the "title" column only the "product description" search works. I would also like to add the ability for the user to hit the enter key in addition to clicking on the Filter button. New to code and looking for some guidance. Thanks. Jim
0
2
108

Jim Sizemore

More actions
bottom of page