Built-in Specialized Columns¶
-
class
webgrid.
LinkColumnBase
(*args, **kwargs)[source]¶ Base class for columns rendering as links in HTML.
Expects a subclass to supply a create_url method for defining the link target.
- Notable args:
link_label (str, optional): Caption to use instead of extracted data from the record.
- Class attributes:
link_attrs (dict): Additional attributes to render on the A tag.
-
class
webgrid.
BoolColumn
(*args, **kwargs)[source]¶ Column rendering values as True/False (or the given labels).
- Notable args:
reverse (bool, optional): Switch true/false cases.
true_label (str, optional): String to use for the true case.
false_label (str, optional): String to use for the false case.
-
class
webgrid.
YesNoColumn
(*args, **kwargs)[source]¶ BoolColumn rendering values as Yes/No.
- Notable args:
reverse (bool, optional): Switch true/false cases.
-
class
webgrid.
DateColumnBase
(*args, **kwargs)[source]¶ Base column for rendering date values in specified formats.
Designed to work with Python date/datetime/time and Arrow.
- Notable args/attributes:
html_format (str, optional): Date format string for HTML.
csv_format (str, optional): Date format string for CSV.
xls_num_format (str, optional): Date format string for Excel.
-
class
webgrid.
DateColumn
(*args, **kwargs)[source]¶ Column for rendering date values in specified formats.
Designed to work with Python date and Arrow.
- Notable args/attributes:
html_format (str, optional): Date format string for HTML.
csv_format (str, optional): Date format string for CSV.
xls_num_format (str, optional): Date format string for Excel.
-
class
webgrid.
DateTimeColumn
(*args, **kwargs)[source]¶ Column for rendering datetime values in specified formats.
Designed to work with Python datetime and Arrow.
- Notable args/attributes:
html_format (str, optional): Date format string for HTML.
csv_format (str, optional): Date format string for CSV.
xls_num_format (str, optional): Date format string for Excel.
-
class
webgrid.
TimeColumn
(*args, **kwargs)[source]¶ Column for rendering time values in specified formats.
Designed to work with Python time and Arrow.
- Notable args/attributes:
html_format (str, optional): Date format string for HTML.
csv_format (str, optional): Date format string for CSV.
xls_num_format (str, optional): Date format string for Excel.
-
class
webgrid.
NumericColumn
(*args, **kwargs)[source]¶ Column for rendering formatted number values.
- Notable args:
format_as (str, optional): Generic formats. Default “general”. - general: thousands separator and decimal point - accounting: currency symbol, etc. - percent: percentage symbol, etc.
places (int, optional): Decimal places to round to for general. Default 2.
curr (str, optional): Currency symbol for general. Default empty string.
sep (str, optional): Thousands separator. Default empty string.
dp (str, optional): Decimal separator. Default empty string.
pos (str, optional): Positive number indicator. Default empty string.
neg (str, optional): Negative number indicator for general. Default empty string.
trailneg (str, optional): Negative number suffix. Default empty string.
xls_neg_red (bool, optional): Renders negatives in red for Excel. Default True.
- Class attributes:
xls_fmt_general, xls_fmt_accounting, xls_fmt_percent are Excel number formats used for the corresponding format_as setting.
-
html_decimal_format_opts
(data)[source]¶ Return tuple of options to expand for decimalfmt arguments.
places, curr, neg, and trailneg attributes are passed through unless format_as is “accounting”.
-
render_html
(record, hah)[source]¶ HTML render override for numbers.
If format is percent, the value is multiplied by 100 to get the render value.
Negative values are given a “negative” CSS class in the render.
-
xls_construct_format
(fmt_str)[source]¶ Apply places and xls_neg_red settings to the given number format string.
-
property
xlsx_style
¶ Number format for XLSX target.