Allow ordering locations by name alphabetically #6797

Closed
opened 2025-12-29 19:45:31 +01:00 by adam · 5 comments
Owner

Originally created by @cronicded on GitHub (Aug 10, 2022).

Originally assigned to: @jeremystretch on GitHub.

NetBox version

v3.2.8

Feature type

Change to existing functionality

Proposed functionality

Make [Organization->Locations-> Name] column sortable, or a sorting reset 'button'

With first use and never sorting by any column, the [Organization->Locations->Name] column defaults to alphabetical order (nested locations in the correct 'tree' order). If a user sorts by any column, there is no option to sort by Name or return to original 'view'.

This is seen in v3.2.2 and tested through v3.2.8

image

Use case

Sorting by any (all) columns expected. Possibly replaced by column/sort reset 'button'.

Similar request/expected sortability behavior found in the following issue: https://github.com/netbox-community/netbox/issues/9477

Database changes

No response

External dependencies

No response

Originally created by @cronicded on GitHub (Aug 10, 2022). Originally assigned to: @jeremystretch on GitHub. ### NetBox version v3.2.8 ### Feature type Change to existing functionality ### Proposed functionality Make [Organization->Locations-> Name] column sortable, or a sorting reset 'button' With first use and never sorting by any column, the [Organization->Locations->Name] column defaults to alphabetical order (nested locations in the correct 'tree' order). If a user sorts by any column, there is no option to sort by Name or return to original 'view'. This is seen in v3.2.2 and tested through v3.2.8 ![image](https://user-images.githubusercontent.com/65557566/183947502-6cd7f4c7-5d3e-4ec2-be62-e0a51d754f6f.png) ### Use case Sorting by any (all) columns expected. Possibly replaced by column/sort reset 'button'. Similar request/expected sortability behavior found in the following issue: https://github.com/netbox-community/netbox/issues/9477 ### Database changes _No response_ ### External dependencies _No response_
adam added the status: acceptedtype: feature labels 2025-12-29 19:45:31 +01:00
adam closed this issue 2025-12-29 19:45:31 +01:00
Author
Owner

@jeremystretch commented on GitHub (Aug 10, 2022):

This isn't limited to location names: All models which use MPTT for hierarchy construction (e.g. regions, site groups) have the same limitation currently.

While we should be able to implement this, IIRC it was not done so originally because of complications with annotating the hierarchy. For example, ordering regions by name without hiding the hierarchy indentation is confusing:

Screenshot 2022-08-10 at 15-34-59 Regions NetBox

We need to devise a way to "hide" the annotation when not ordering by hierarchical position. Which raises a second issue: how do we differentiate between ordering by hierarchy and ordering alphabetically?

Even if we eschewed restoration of the hierarchical order (short of a page refresh), we would need a way to infer in the table column whether or not to render the indentation. As far as I can tell from the TemplateColumn docs, this doesn't seem to be feasible.

@jeremystretch commented on GitHub (Aug 10, 2022): This isn't limited to location names: All models which use MPTT for hierarchy construction (e.g. regions, site groups) have the same limitation currently. While we should be able to implement this, IIRC it was not done so originally because of complications with annotating the hierarchy. For example, ordering regions by name without hiding the hierarchy indentation is confusing: ![Screenshot 2022-08-10 at 15-34-59 Regions NetBox](https://user-images.githubusercontent.com/13487278/184004682-d7770871-a4e4-4f6d-ad64-a8992effb79c.png) We need to devise a way to "hide" the annotation when not ordering by hierarchical position. Which raises a second issue: how do we differentiate between ordering by hierarchy and ordering alphabetically? Even if we eschewed restoration of the hierarchical order (short of a page refresh), we would need a way to infer in the table column whether or not to render the indentation. As far as I can tell from [the TemplateColumn docs](https://django-tables2.readthedocs.io/en/latest/pages/api-reference.html#templatecolumn), this doesn't seem to be feasible.
Author
Owner

@cronicded commented on GitHub (Aug 10, 2022):

Which raises a second issue: how do we differentiate between ordering by hierarchy and ordering alphabetically?
Agreed, Resetting via Configure Table ended up sorting in this manner:

image

I did find my expected/intended 'view' when reviewing Locations under the Site link with the 'correct' ordering and nesting:

image

Perhaps this helps with the review/implementation?

@cronicded commented on GitHub (Aug 10, 2022): > Which raises a second issue: how do we differentiate between ordering by hierarchy and ordering alphabetically? Agreed, Resetting via Configure Table ended up sorting in this manner: ![image](https://user-images.githubusercontent.com/65557566/184024784-98e61ab0-5e72-4d2d-8337-ae1d44f57f19.png) I did find my expected/intended 'view' when reviewing Locations under the Site link with the 'correct' ordering and nesting: ![image](https://user-images.githubusercontent.com/65557566/184024296-de35bee3-0e8c-446e-8932-5a5d9afb8018.png) Perhaps this helps with the review/implementation?
Author
Owner

@jeremystretch commented on GitHub (Aug 31, 2022):

If a user sorts by any column, there is no option to sort by Name or return to original 'view'.

This should be addressed by the implementation of #9477.

@jeremystretch commented on GitHub (Aug 31, 2022): > If a user sorts by any column, there is no option to sort by Name or return to original 'view'. This should be addressed by the implementation of #9477.
Author
Owner

@github-actions[bot] commented on GitHub (Nov 16, 2022):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Nov 16, 2022): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. **Do not** attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@jeremystretch commented on GitHub (Dec 15, 2022):

I've implemented for all self-nested models:

  • Location
  • Region
  • SiteGroup
  • ContactGroup
  • TenantGroup
  • WirelessLANGroup
@jeremystretch commented on GitHub (Dec 15, 2022): I've implemented for all self-nested models: - Location - Region - SiteGroup - ContactGroup - TenantGroup - WirelessLANGroup
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#6797