Hi Paul,

You can test if the grid has rows by doing the following

{{if grid.rows:}}
  {{=grid.rows}}
{{else:}}
  No records
{{pass}}


That should do it I think.

Regards, Edwin

On Monday, February 13, 2017 at 7:12:53 PM UTC+4, Paul Ellis wrote:
>
> I want to display something else if the query returns empty. Like some 
> instructions and buttons. 
>
> I can't find anything in the SQLFORM.grid signature, like an on_empty 
> option and haven't found anything in the book or by googling.
>
> As the Add button doesn't fit this situation. I am getting a DIV with the 
> text 'No records Found' not an empty grid.
>
> How can I do this without checking the DB for rows before calling the 
> grid? This would then be accessing the DB twice when there are rows to be 
> displayed which is most of the time.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to