Available Built-in Formatters
The tables extension comes with several built-in formatters that you can use to format the data in your table columns.
Using formatter is simple; you just need to import the desired formatter from ckanext.tables.shared.formatters and add it to the formatters list in the ColumnDefinition.
from ckanext.tables.shared import formatters, ColumnDefinition
ColumnDefinition(
field="timestamp",
formatters=[(formatters.DateFormatter, {"date_format": "%Y-%m-%d %H:%M"})],
)
Below is a list of the available built-in formatters along with a brief description of each.
ActionsFormatter
Renders a template snippet to display row-level actions.
BooleanFormatter
Renders a boolean value as 'Yes' or 'No'.
DateFormatter
Formats a datetime object into a more readable date.
DialogModalFormatter
Renders a link that opens a dialog modal with detailed information.
JsonDisplayFormatter
Renders a JSON object using a template snippet for display.
Must be combined with tabulator_formatter="html" in the ColumnDefinition
to ensure proper HTML rendering in the frontend.
ListFormatter
Renders a list as a comma-separated string.
NoneAsEmptyFormatter
Renders a None value as an empty string.
TextBoldFormatter
Renders text in bold.
TrimStringFormatter
Trims a string to a specified maximum length.
URLFormatter
Generates a clickable link for a URL.
UserLinkFormatter
Generates a link to a user's profile with a placeholder avatar.
This is a custom, performant implementation that avoids expensive
user_show calls for every row by using a placeholder.
The value for this formatter should be a user ID.