Hi!
In my site you can filter on a table by a date and it shows you the results in a repeater.
I want the page to pop a message if a filter returned empty results.
my code is this:
$w ( "#dataset1" ). onReady (() => {
$w ( "#dataset1" ). setFilter ( wixData . filter ()
. between ( "date" , dateValue1 , dateValue2 )
. eq ( '_owner' , userID )
)
Just create a text element (ex: $w(‘#txtNoData’) ) with the text you want, mark it as collapsed on load , and use the .expand() method to expand it, if $w ( “#dataset1” ) .getTotalCount() method returns 0.
Like this:
$w.onReady(() => {
$w('#dataset1').onReady(async () => {
await $w('#dataset1').setFilter(
wixData
.filter()
.between('date', dateValue1, dateValue2)
.eq('_owner', userID)
)
const dataCount = $w('#dataset1').getTotalCount()
if (dataCount === 0) {
$w('#txtNoData').expand()
} else {
$w('#txtNoData').collapse()
}
})
})