I have a repeater that displays 12 items at a time from a dynamic dataset using a Pagination widget. This works as expected.
I also allow Searching on this dataset for a String in the Subject field. By default, if you use pagination on a search, clicking the next page will show you the next item in the database regardless of whether it matches the search string.
To get around this I am setting a Session Variable to the Date field of the items in the search. When a search is initiated via a Search Button next to the Search input field, the Pagination is turned off and replaced with a next button. The initial Search produces the expected results.
The “Next Match” button function gets the Session Variable and uses it in a new search.
I have implemented this in another page and it is working as expected but this one returns NO data even though I know it is there. See the two screen shots … one with search limit set to 6 and the other one set to 12. With it set to 6, the Next page should show messages beginning with #5625 on…
with search limit set to 12…
Here is the code:
export function repeater1_itemReady($w, itemData, index) {
let itemEmail = itemData.email;
let itemMsg = itemData.msg;
session.setItem(“Next”, itemMsg);
console.log(“REPEATER READY MSG: “, itemMsg)
let itemSeq = 1;
$w(”#repeater1”).show(); //JDS
}
export function searchButton_click(event) {
$w(“#pagination1”).hide();
$w(“#searchingGif”).show();
$w(“#repeater1”).hide();
$w(“#nextPage”).show();
Search = $w("#searchField").value
wixData.query('CVOA-Yahoo-Board')
.contains('subject', Search)
.limit(6)
.ascending('date')
.find()
.then(res => {
$w('#repeater1').data = res.items;
$w("#searchingGif").hide();
$w("#repeater1").show();
})
}
export function nextPage_click(event) {
let last = session.getItem(“Next”);
console.log(“next: “, last)
wixData.query(‘CVOA-Yahoo-Board’)
.contains(‘subject’, Search)
.gt(“msg”, last)
.ascending(‘date’, ‘msg’)
.limit(6)
.find()
.then(res => {
$w(‘#repeater1’).data = res.items;
$w(”#repeater1”).show();
})
}
------------------------
As you can see, I am console logging the sessionSet and sessionGet… on the “nextPage” I do see it should be continuing search from previous search. F12 shows no errors in the java console.
As I stated, I have another page where this works perfectly. I cannot seem to find out the difference. In fact, I copied that code and changed it to match this page, still same results (or lack thereof) on the “nextPage”…
Please help!
Thanks
JD