It doesn’t work
This doesn’t work because the repeating panel is generated when items
is assigned.
It will work if you do this:
results = list(results)
random.shuffle(results)
self.repeating_panel_1.items = results
It’s slow
I think you can speed up things by executing the list(results)
on the server side.
I think that search
will fetch the first batch of rows (~100), then list(result)
will add batches as needed, as it goes through the comprehension.
If you do it on the client, you end up with 1 round trip per batch, 20000/100=200 round trips (assuming each batch is 100 rows).
If you do it on the server, you end up with 200 accesses to the database, but without the round trips, and it should be faster.
20000 items on a repeating panel
The next consideration is about creating a repeating panel with 20000 items…
Generating 20000 forms, even if they are simple, could take some time.
If the repeating panel is inside a DataGrid with pagination enabled, then you will quickly see the first page. But if the user clicks on the last button to go to the last page, you will trigger the generation of all 20000 forms (unless I’m wrong and the DataGrid is smart enough to only generate the forms on the last page).
So, if you are using the DataGrid, I suggest to test what happens if the user clicks on the last page button, and, if it’s too slow, to remove the navigation buttons and create your own, with the first 3 buttons and without the last page button.
If you are not using the DataGrid, you could have a look at this so you add a few rows at a time instead of waiting the generation of 20000 forms at once.