What I’m trying to do:
I want to find out the number of reords in a datatable and the number of entries(rows) in a datagrid .
Is there a method or property to calculate this?
What I’ve tried and what’s not working:
I search the docs but didn’t find a solution
For the data table, does this not work for you (not tried it) ?
num_rows=len(app_tables.<tablename>.search() )
Taken from this post :
Also, see the docs here :
Here’s an extract from that page :
Search is lazy
search() returns a search object, which is iterable - you can use it in a for loop or a list comprehension. If your search returns lots of results, Anvil only loads a few at a time.
You can call len() on a search object to efficiently find out how many rows it would return (without loading them all!).
print(f"There are {len(app_tables.people.search())} people")
For the data grid, use len() on the repeating_panel, as it’s just an array :