I have the following code which uses the setPageSize for my repeater to display 1 item. If there is more than 1 item then the LOAD MORE (button3) shows. If a user selects the LOAD MORE and then changes the dropdown3 value, the repeater doesn't reset the setPageSize back to 1. If the user pressed the LOAD MORE 2 more times to display 3 items, when they change the dropdown3 value to something else the repeater doesn't reset the setPageSize back to 1 it will use the 3 instead.
Any insight to how to correct this so that each time the user changes the dropdown3 value, the setPageSize will also reset to 1?
export function dropdown3_change(event) { var maxShow = 1; $w("#dataset2").setPageSize(maxShow); console.log(maxShow); $w("#dataset2").setFilter(wixData.filter() .eq("platform",$w("#dropdown3").value) .ne("hide",true) ) .then(() => { let totalCount = $w("#dataset2").getTotalCount(); //console.log(totalCount); if ( totalCount > maxShow) { $w("#button1").show(); } else { $w("#button1").hide(); } }); }
To add to this, in doing a console.log, the setPageSize is resetting to 1, but the data is still pulling 3. It seems the repeater is ignoring the setPageSize value after the initial page load.
Perhaps....
import wixData from "wix-data"; $w.onReady(()=>{ $w("#dataset2").onReady(()=>{ $w('#dropdown3').onChange((event)=>{ setTimeout(()=>{ let maxShow = 1; xxx(maxShow) },50) }) $w('#button1').onClick(()=>{ $w("#dataset2").loadMore(); }) }) }) async function xxx (maxShow) {console.log(maxShow); await $w("#dataset2").setPageSize(maxShow); $w("#dataset2").setFilter(wixData.filter() .eq("platform",$w("#dropdown3").value) .ne("hide",true) ) .then(() => { let totalCount = $w("#dataset2").getTotalCount(); console.log(totalCount); if ( totalCount > maxShow) {$w("#button1").show();} else {$w("#button1").hide();} }); }
Try this one. And next time --> please use CODE-TAGs for CODE-SNIPETS! 😉
I do not know if this will work, but give it a try 😁
export function dropdown3_change(event) { setTimeout(()=>{ let maxShow = 1; xxx(maxShow) },50) } function xxx (maxShow) {console.log(maxShow); $w("#dataset2").setPageSize(maxShow); $w("#dataset2").setFilter(wixData.filter() .eq("platform",$w("#dropdown3").value) .ne("hide",true) ) .then(() => { let totalCount = $w("#dataset2").getTotalCount(); console.log(totalCount); if ( totalCount > maxShow) {$w("#button1").show();} else {$w("#button1").hide();} }); }