pallets-eco / flask-admin

Simple and extensible administrative interface framework for Flask
BSD 3-Clause "New" or "Revised" License
5.69k stars 1.56k forks source link

Enhancement: Allow page_size_options = [15,30,60] to override 20,50,100 hard coded into page_size_form layout #2412

Open macnewbold opened 5 months ago

macnewbold commented 5 months ago

I don't know know if others run into this like I do, but it would be an enhancement I think would be useful.

Currently, you can set page_size, like say to 15 rows, and you can set can_set_page_size to true, but if you do, the dropdown list of page size choices still only has 20, 50, and 100. Currently the only way to override it is to copy and paste page_size_form from its layout and override it, by copy paste and tweak, to add different options. I think it would be really nice if the hard coded entries like this:

<a class="dropdown-item{% if page_size == 20 %} active{% endif %}" href="{{ generator(20) }}">20 {{ _gettext('items') }}</a>

could be driven by a configuration variable that provides a list of integers as the desired entries, and prints out one of these for each entry n in the list:

<a class="dropdown-item{% if page_size == n %} active{% endif %}" href="{{ generator(n) }}">n {{ _gettext('items') }}</a>