Repeater panel descending order

Hello,
I’d like my repeater panel to display list items in descending order. I have a report-type app, and the index is a date column which should display the most recent at the top. Is there a property available?

Steven

Hi Steven,

The RepeatingPanel displays everything from its items property, in order. If you want to set the order, you can just sort the items list! There are two ways of doing it:

  1. Sort it in Python. You can call sort() on a Python list, or use the sorted() function on any iterable object. Then just set the items property of the RepeatingPanel to the sorted collection.

  2. Fetch the items in order from the database. Anvil’s Data Tables include the function tables.order_by(column_name), so you can do something like this:

    records = app_tables.my_records.search(tables.order_by('date_added', ascending=False))
    

Hope that helps!

1 Like

3 posts were split to a new topic: Sort repeating panel on multiple columns