ckanext-hierarchy
ckanext-hierarchy copied to clipboard
Pagination breaks organization display
I see this behavior on both CKAN 2.7 and 2.8. I have 32 organizations 5 top-level that each have 4-7 sub-organizations. This many organizations causes the interface to add a pager, which breaks the display of all organizations with some child organizations being displayed individually & repeated with the proper hierarchy on the 2nd page. A simple solution for my case could be to disable paging / allow more items per page, but I am unsure where this is changed.
Is there a work around for this as I have the same problem?
If you have more than 20, but not a ton I do have a workaround:
The underlying issue is that the organization list display controller (in base ckan) is set to return a specified number of items per page. It searches and finds the matching organizations (limited to 21 items per page) and passes them to the hierarchy plugin to display. The hierarchy plugin then tries to build the tree, but it is missing pieces because of the per page limit.
The easiest solution is to edit the CKAN group controller here to be a number larger than your number of organizations: https://github.com/ckan/ckan/blob/197f9b19254dad3056d1418d4bbfc5c604b39c4e/ckan/controllers/group.py#L144
FYI, It looks like future versions of CKAN will use the datasets_per_page config variable to determine the limit.
Thanks for the tip but when you think about it, pagination don't make sens with this module as it will always break the display of the tree.
I tried to use the following in templates/organization/index.html of the ckan core module:
{% snippet "organization/snippets/organization_list.html", organizations=organizations, show_capacity=True %}
This will display the whole tree. Unfortunatly, when I use search, highlight of results dont work. So for the moment, your solution works better but I'm sure it can be fixed in this module.