Show "no results found" if no relevant results in the dataset

Hi,

I have two filter boxes that display results from a repeater dataset. I’d like to add the functionality of showing a message saying “no results found” when the filters are added and there are no relevant results.

This is my code for the filter function. I also have the text box added to the site and hidden called #textNoRes

I’ve looked through the forum and tried to add this myself using different pieces of code but can’t seem to figure out the correct combo.

import wixData from ‘wix-data’ ;

$w . onReady ( function () {
$w ( “#dataset1” ). onReady (() => {
$w ( “#repeater1” ). onItemReady (( $item , itemData , index ) => {
$item ( “#textDateType” ). text = itemData . dates + ", " + itemData . time + " | " + itemData . courseType ;
$item ( “#textTitle” ). text = itemData . title ;
$item ( “#textInstructorLocation” ). text = itemData . instructorName + " | " + itemData . location ;
})
});
});

export function dropdown1_change ( event ) {
$w ( “#dataset1” ). setFilter ( wixData . filter ()
. eq ( “ce” , true )
. contains ( “courseType” , $w ( “#dropdown1” ). value )
. contains ( “instructorName” , $w ( “#dropdown2” ). value )
)
. then (()=>{
$w ( “#boxClear” ). expand ();
})
}

export function dropdown2_change ( event ) {
$w ( “#dataset1” ). setFilter ( wixData . filter ()
. eq ( “ce” , true )
. contains ( “courseType” , $w ( “#dropdown1” ). value )
. contains ( “instructorName” , $w ( “#dropdown2” ). value )
)
. then (()=>{
$w ( “#boxClear” ). expand ();
})
}

export function buttonClear_click ( event ) {
$w ( “#dropdown1” ). value = undefined ;
$w ( “#dropdown2” ). value = undefined ;
// $w(“#dropdown3”).value = undefined;
$w ( “#boxClear” ). collapse ();
$w ( “#dataset1” ). setFilter ( wixData . filter ()
. eq ( “ce” , true )
)
}

Thank you for your help!

You could just create a new strip and put whatever text you want to be displayed (I.E. “No results found please select a different date or time”). In the $w.onReady function you can then hide this strip by default with $w(“#stripid”).hide(). Finally you can set up an if else statement to check if data was returned from the dataset. If not then just show the strip with $w(“#stripid”).show()

There are other ways of accomplishing something similar, but this might be the easiest one