Skip to Content

Data Table V2

For: implementers. componentId: data_table_v2. Setup: setting names match the ModularIoT web app.

Shows rows in a table. Viewers can filter and sort columns, change their width and export to CSV.

Table with Id, Estado, Responsable, Creada and Horas

Data it reads

It reads all the rows of its query. Each column shows a template evaluated on each row: {{row.estado}}.

SELECT id, estado, responsable, FORMAT_TIMESTAMP('%Y-%m-%d %H:%M', creada_en, 'America/Santiago') AS creada_en, CAST(horas AS STRING) AS horas FROM `my-project.operations.solicitudes` ORDER BY creada_en DESC LIMIT 500

When you choose the query in Variable, the table columns are replaced by the query’s columns, with labels generated from the names (creada_en → Creada En).

Variants

VariantSettingsQuery shapeScreenshot
BasicColumns with {{row.column}}; Suffix h on HorasOne row per recordBasic
State with colorEstado column with type badge and color rules (paintbrush)The sameState with color
Colored rowsColoring: Horas greater than 30 → redThe sameColored rows
Row actionsUtilities › Add actionA column with the id for the linkRow actions

Basic

Basic table with 12 items

State with color

Estado column with yellow and blue badges

  1. Choose the query in Variable first. Choosing it later replaces the columns and drops their colors.

  2. On the Estado column card, type badge in the first field under the key.

  3. Turn on the paintbrush and add one rule per state:

    OperatorValueColor
    =pendienteeab308 (yellow)
    =en_curso3b82f6 (blue)
    =cerrada22c55e (green)

Rules compare the text the cell shows. If the query turns en_curso into In progress with CASE, write In progress in the rule.

Colored rows

Row with 37 hours marked in red

Pitfall: Coloring rules added from the UI are not applied: the widget saves rowColorRules.enabled: false and the section has no switch. Write "enabled": true in the document (Import and export).

Row actions

Table with a three-dot menu at the end of each row

ActionUsed by
The first one (Primary action)Clicking the row. Ctrl or Cmd + click opens another tab
The others (Secondary actions)The three-dot menu and right-click on the row

The link accepts templates: /app/en/requests/{{row.id}}. Only http, https, mailto, tel or relative links are allowed.

Settings

SectionSettingDocument keyEffect
GeneralTitletitlePlain text. No templates. Also the CSV file name
GeneralRow countshowRowCount”12 items”. Counts rows after filters
GeneralColumn dividersshowColumnDividersLines between columns
GeneralShow exportshowExportCSV download button
GeneralStriped rowsstripedAlternating background
UtilitiesAdd actionrowActions[]: name, link, targetSee Row actions
ColumnsKeycolumns[].keyCell template: {{row.estado}}
ColumnsCard titlecolumns[].labelHeader
ColumnsFirst text fieldcolumns[].typeHow it is drawn: text, badge, signed, progress
ColumnsSecond text fieldcolumns[].dataTypeType for the filter: text, number, date, enum, boolean. Empty: detected
ColumnsSuffixcolumns[].decoratorSmall text after the value. Not in the CSV
ColumnsPaintbrushcolorRulesEnabled, colorMap[]Text or badge color by value
ColumnsQuestion markdescriptionEnabled, descriptionHelp on the header (Markdown)
ColumnsPinstickyFreezes the column on horizontal scroll. Edge columns only
ColoringAdd rulerowColorRulesRow background color
Data ProviderData Source, VariabledataMode, plannerVariableName, rowsIn static mode, rows go in rows

Column types

typeDrawn as
textText. If the value has a line break, the first line is bold
badgeBadge. Takes the color of the matching rule
signedNumber in red when negative, orange from 0 to 999, green from 1000
progressBar from 0 to 100 with the number

To format numbers or dates, use template functions in the key: {{formatNumber row.amount prefix="$"}}. See Templates.

What viewers can do

ActionHowSaved
Filter a columnFunnel on the header. Search, value list, number or date rangeNo
SortClick the header of a sortable columnNo
Change the widthDrag the three dots in the header; Enter or double-click fitsOnly in Edit Mode
ExportDownload button › CSV—

The CSV holds the visible rows after filters and sort, separated by ;, in UTF-8.

Filtering and sorting work when the column key is {{row.column}}. With a function ({{formatDate row.date}}), that column’s filter and sort have no effect. Format in the query if you need both.

Full example

{ "componentId": "data_table_v2", "config": { "title": "Detalle de solicitudes", "showRowCount": true, "showColumnDividers": true, "showExport": true, "dataMode": "planner", "plannerVariableName": "detalle", "columns": [ { "key": "{{row.id}}", "label": "Id", "type": "text" }, { "key": "{{row.estado}}", "label": "Estado", "type": "badge", "colorRulesEnabled": true, "colorMap": [ { "operator": "equals", "value": "pendiente", "color": "eab308" }, { "operator": "equals", "value": "en_curso", "color": "3b82f6" }, { "operator": "equals", "value": "cerrada", "color": "22c55e" } ] }, { "key": "{{row.responsable}}", "label": "Responsable", "type": "text" }, { "key": "{{row.horas}}", "label": "Horas", "type": "text", "decorator": "h" } ], "sort": { "enabled": true, "columns": ["{{row.id}}", "{{row.horas}}"] }, "rowColorRules": { "enabled": true, "rules": [{ "column": "{{row.horas}}", "operator": "greater_than", "value": "30", "color": "ef4444" }] } } }

Limits

LimitAlternative
Draws every row, no paging. More than 5,000 rows makes the query failLimit in the query (LIMIT 500)
Sortable columns cannot be chosen in the UIWrite sort.columns in the document
Choosing the query replaces the columns and drops colors, suffixes and descriptionsChoose the query before setting up the columns
Coloring rules added in the UI are not applied"enabled": true in the document
A BigQuery TIMESTAMP shows as seconds in scientific notation (1.7933364E9)FORMAT_TIMESTAMP in the query
Values must be text ("30", not 30) for filtering and sortingQuote the values in rows. Saved queries already return text
Last updated on