1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Document supported table columns

This commit is contained in:
jeremystretch
2022-02-09 14:31:40 -05:00
parent 23a80770e1
commit ee566723d7
2 changed files with 59 additions and 5 deletions

View File

@ -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

View File

@ -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