In some cases your query may return no results so it is useful to be able to show a message, telling the users no results are returned. In Wappler this can be done using the dynamic show/hide attributes.
We have a page, which lists records from a database query. We added a title above our records and we will configure this title to only show when no records are returned:
Click the element you want to show (in our case this is a title, but can be any other HTML element) and then add new dynamic attribute:
Open the display category and select show:
Then click the dynamic data picker, to select a condition when to show this message:
Select the query, which returns your results(1) and click the data formatter icon(2):
Right click the expression, and from the Conditional menu, select Has Items:
Click the select button to apply this formatting option:
Currently the condition checks if the query has items and if we leave it like that, it will show the message when the query returns records. However we need it to show when the query returns no items. All we have to do is to add an
! before the expression, like
And we are done. The message saying “no items” will only be displayed when the query returns no results.