From 1ccab930ef16bd5ebab708fae0468295eeaa9076 Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 2 Apr 2026 10:10:35 -0400 Subject: [PATCH] Enable specifying column grid width --- netbox/netbox/ui/layout.py | 9 ++++++++- netbox/templates/generic/object.html | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/netbox/netbox/ui/layout.py b/netbox/netbox/ui/layout.py index 603df2f86..375417288 100644 --- a/netbox/netbox/ui/layout.py +++ b/netbox/netbox/ui/layout.py @@ -58,12 +58,19 @@ class Column: Parameters: *panels: One or more Panel instances + width: Bootstrap grid column width (1-12). If unset, the column will expand to fill available space. """ - def __init__(self, *panels): + def __init__(self, *panels, width=None): for i, panel in enumerate(panels): if not isinstance(panel, Panel): raise TypeError(f"Panel {i} must be an instance of a Panel, not {type(panel)}.") + if width is not None: + if type(width) is not int: + raise ValueError(f"Column width must be an integer, not {type(width)}") + if width not in range(1, 13): + raise ValueError(f"Column width must be an integer between 1 and 12 (got {width}).") self.panels = panels + self.width = width def __iter__(self): return iter(self.panels) diff --git a/netbox/templates/generic/object.html b/netbox/templates/generic/object.html index c227772cc..0edfc2605 100644 --- a/netbox/templates/generic/object.html +++ b/netbox/templates/generic/object.html @@ -127,7 +127,7 @@ Context: {% for row in layout %}
{% for column in row %} -
+
{% for panel in column %} {% render panel %} {% endfor %}