Remember the users filter selection

Hi Joe, here’s code you could use. In this example, Dataset1 is used as a filter for another dataset. The session storage saves the settings. ‘session’ could also be saved to ‘memory’ for a shorter term storage.

import {session} from 'wix-storage';

export function dataset1_currentIndexChanged() {
    let currentindex = $w('#dataset1').getCurrentItemIndex()
    $w('#text1').text = $w('#text1').text + "s" + currentindex
    session.setItem("selectedentry", currentindex);
}

export function dataset1_ready() {
    let selectedindex = Number(session.getItem("selectedentry"));
    $w('#text1').text = $w('#text1').text + "l" + selectedindex
    $w('#dataset1').setCurrentItemIndex(selectedindex)
}

Note that the lines starting with $w(‘#text1’) can be omitted. I have used the text1 item to check when the selecteditem is loaded and saved. It turns out that sometimes it’s loaded, saved and then loaded again on one single page load. I’m not sure what’s the best way to prevent multiple loads/saves but the code works, anyway.