Sfoglia il codice sorgente

Document supported table columns

jeremystretch 4 anni fa
parent
commit
ee566723d7
2 ha cambiato i file con 59 aggiunte e 5 eliminazioni
  1. 52 0
      docs/plugins/development/tables.md
  2. 7 5
      netbox/netbox/tables/columns.py

+ 52 - 0
docs/plugins/development/tables.md

@@ -46,3 +46,55 @@ table.configure(request)
 ```
 
 If using a generic view provided by NetBox, table configuration is handled automatically.
+
+## Columns
+
+The table column classes listed below are supported for use in plugins. These classes can be imported from `netbox.tables.columns`.
+
+::: netbox.tables.BooleanColumn
+    rendering:
+      show_source: false
+    selection:
+      members: false
+
+::: netbox.tables.ColorColumn
+    rendering:
+      show_source: false
+    selection:
+      members: false
+
+::: netbox.tables.ColoredLabelColumn
+    rendering:
+      show_source: false
+    selection:
+      members: false
+
+::: netbox.tables.ContentTypeColumn
+    rendering:
+      show_source: false
+    selection:
+      members: false
+
+::: netbox.tables.ContentTypesColumn
+    rendering:
+      show_source: false
+    selection:
+      members: false
+
+::: netbox.tables.MarkdownColumn
+    rendering:
+      show_source: false
+    selection:
+      members: false
+
+::: netbox.tables.TagColumn
+    rendering:
+      show_source: false
+    selection:
+      members: false
+
+::: netbox.tables.TemplateColumn
+    rendering:
+      show_source: false
+    selection:
+      members: false

+ 7 - 5
netbox/netbox/tables/columns.py

@@ -75,7 +75,8 @@ class BooleanColumn(tables.Column):
 
 class TemplateColumn(tables.TemplateColumn):
     """
-    Overrides the stock TemplateColumn to render a placeholder if the returned value is an empty string.
+    Overrides django-tables2's stock TemplateColumn class to render a placeholder symbol if the returned value
+    is an empty string.
     """
     PLACEHOLDER = mark_safe('—')
 
@@ -219,7 +220,7 @@ class ContentTypesColumn(tables.ManyToManyColumn):
 
 class ColorColumn(tables.Column):
     """
-    Display a color (#RRGGBB).
+    Display an arbitrary color value, specified in RRGGBB format.
     """
     def render(self, value):
         return mark_safe(
@@ -232,7 +233,8 @@ class ColorColumn(tables.Column):
 
 class ColoredLabelColumn(tables.TemplateColumn):
     """
-    Render a colored label (e.g. for DeviceRoles).
+    Render a related object as a colored label. The related object must have a `color` attribute (specifying
+    an RRGGBB value) and a `get_absolute_url()` method.
     """
     template_code = """
 {% load helpers %}
@@ -283,7 +285,7 @@ class LinkedCountColumn(tables.Column):
 
 class TagColumn(tables.TemplateColumn):
     """
-    Display a list of tags assigned to the object.
+    Display a list of Tags assigned to the object.
     """
     template_code = """
     {% load helpers %}
@@ -342,7 +344,7 @@ class CustomFieldColumn(tables.Column):
 
 class CustomLinkColumn(tables.Column):
     """
-    Render a custom links as a table column.
+    Render a custom link as a table column.
     """
     def __init__(self, customlink, *args, **kwargs):
         self.customlink = customlink