I would like to load the previous search result in the table (if there was a previous result) or if not load the default listing into the table.
Inside the $w.onReady function there is a an onReady function for the dataSet.
$w("#dataset1").onReady(() => {
wixData.query("Movies")
.limit(1000)
.ascending("title")
.find()
.then((results) => {
$w("#movieCount").text = results.totalCount.toString();
$w("#movieList").rows = results.items; // populate the table
This works everytime the page is loaded.
There is also a click event with it’s own onReady function to do searches.
export function search_click(event, $w) {
$w(“#dataset1”).onReady(() => {
let searchStr = $w(“#searchTerms”).value;
searchStr = searchStr.trim();
if (searchStr) {
wixData.query("Movies")
.contains("title", searchStr)
.or(wixData.query("Movies").contains('action_needed', searchStr))
.or(wixData.query("Movies").contains('genre', searchStr))
.limit(1000)
.ascending("title")
.find()
.then((results) => {
$w("#movieCount").text = results.totalCount.toString();
$w("#movieList").rows = results.items; // populate the table
});
}
This search is also working as expected.
The requirement:
A record is displayed after clicking on the link in the table using the dynamic link (this works).
After the dynamic page is closed the user returns to this page.
We would like the table to redisplay with the prior search result (if any search was previously done, or the entire table if no seach was previously done)
Then scroll to record that was previously clicked on and select the row.
What can be done to reload the table in the same state and scroll to the last used record?