How to add sorting functionality to datagrid with repeating panels?

If the sorting is always on the same column, then you can get the list sorted by the database as @jshaffstall suggests.

If the list has few items (100 is a few), then you can sort it when you assign it. Something like this (untested, I’m on my cell now):

repeating_panel.items = sorted(items, key=lambda row: row['key'])

If you want the user to decide which column to order by and you are showing plain numbers or text (nothing fancy in the template form), then you can use the DataGridJson. I use it on all my production apps, it’s a time saver and makes my apps look consistent to each other.

1 Like