@russian-dima hi again V-N. I have spent much of today, rebuilding the page in question and I have now managed to get it doing what I require in terms of the url and using wix-storage to keep the dropdown on the selection after the page changes.
However, having found solutions to every other problem I have encountered, I do have one issue I am struggling to resolve. My setup still has a dependent dropdown system on page 1 which works fine ie when I pick an option from the #classDropDown the correct list appears in #numberDropDown and picking from this dropdown redirects to page 2 where the results are shown. The issue arises on page 2 because I would like the #numberDropDown to continue just showing the list that relates to the selection in #classDropDown enabling the user to cycle through these if they wish. Unfortunately though the filter isn’t working and irrelevant of what is in #classDropDown, everything from the database is showing in the #numberDropDown.
As an example of what I mean, if “1” is selected in #classDropDown, then #numberDropDown would show a list from 1-10 and if “2” is selected it would show 11-20.
Below is the code for page 2 of my setup
import wixLocation from 'wix-location';
import wixData from 'wix-data';
import {local} from 'wix-storage';
$w.onReady(function () {
NumberChange();
uniqueDropDown2();
var sameDropDown = local.getItem("class2");
$w('#classDropDown').value = sameDropDown;
$w('#classDropDown').placeholder = sameDropDown;
var sameDropDown2 = local.getItem("number1");
$w('#numberDropDown').value = sameDropDown2;
$w('#numberDropDown').placeholder = sameDropDown2;
});
function uniqueDropDown2(){
wixData.query('LocomotiveLogsTest')
.contains("class2", $w('#classDropDown').value)
.ascending('number1')
.limit(1000)
.find()
.then(results =>{
const uniqueTitles = getUniqueTitles(results.items);
$w('#numberDropDown').options = buildOptions(uniqueTitles);
});
function getUniqueTitles(items) {
const titlesOnly = items.map(item => item.number1);
return [...new Set(titlesOnly)];
}
function buildOptions(uniqueList) {
return uniqueList.map(curr =>{
return {label:curr, value:curr};
});
}
}
function NumberChange () {
$w('#numberDropDown').onChange((event) => {
let number = $w('#numberDropDown').value;
$w('#dynamicDataset').onReady(() => {
console.log("The dataset is ready to be filtered.");
$w('#dynamicDataset').setFilter(wixData.filter()
.eq("number1", number)
)
.then(() => {
console.log("Dataset1 dataset is now filtered with the matching title from the dropdown");
let getItem = $w('#dynamicDataset').getCurrentItem();
let url = wixLocation.to(`/locomotive-logs-test/${$w("#numberDropDown").value}`);
let activeDynamicItem = $w('#dynamicDataset').getCurrentItem();
let fieldX = activeDynamicItem['photoCredit'];
console.log(fieldX);
console.log(activeDynamicItem);
if (fieldX && fieldX === "") {
$w('#text488').collapse();
} else {
$w('#text488').expand();
}
})
.catch((err) => {
console.log(err);
});
});
});
}
export function button12_click(event) {
local.clear();
}
export function button15_click_1(event) {
$w('#text484').expand();
$w('#text482').expand();
$w('#text485').expand();
$w('#text483').expand();
$w('#image15').show();
$w('#image14').collapse();
$w('#button14').show();
$w('#button15').hide();
$w('#text488').collapse();
}
export function button14_click(event) {
$w('#text484').collapse();
$w('#text482').collapse();
$w('#text485').collapse();
$w('#text483').collapse();
$w('#image15').hide();
$w('#image14').expand();
$w('#button14').hide();
$w('#button15').show();
$w('#text488').expand();
}
My gut feeling is telling me that the line I have highlighted above is where the issue is arising because on page 2 the info in #classDropDown is coming across from page 1 via the wix-storage set/getItem which I think may be impacting on the filtering from the dataset.
I’m hoping you can shunt me in the right direction as I have just ticked over 10 hours worth of time spent on this today and I’m tiring haha.
Thanks