TABLE GUIDE: the table block and AG Grid 35.3 Community (dashboard schema 1.14)

StrataBI's table block is AG Grid Community 35.3 (dash-ag-grid 35.3.0, which bundles ag-grid-community 35.3.1;
the grid's CSS is served by StrataBI itself). This guide says what that grid can do, written as table-block
config. Only Community features are loaded: an Enterprise option does nothing on the page (at most a message in
the browser console), so use the native alternative listed below.

0. WHERE AG GRID OPTIONS GO IN A TABLE CONFIG
  "block": {"type": "table", "config": {
    "column_defs":       [ {AG Grid column definition + StrataBI "format"}, ... ]   (columnDefs)
    "default_col_def":   {applies to every column}       StrataBI sets sortable, filter, resizable: true
    "dash_grid_options": {grid options}                  StrataBI sets theme "legacy", pagination, page size
    "page_size": 25, "pagination": true, "height": "420px", "max_rows": 100000,
    "className": "ag-theme-alpine" | "ag-theme-alpine-dark"   (omit: follows the app theme)
  }}
  Values are JSON. Where AG Grid wants a function, Dash AG Grid takes a string expression instead:
  cellClassRules / rowClassRules values and cellStyle "styleConditions" conditions are evaluated with
  `params` (params.value, params.data.<column>), e.g. "params.value > 100".

1. WHAT WORKS (Community 35.3)
  SORTING      on by default. Initial order: "sort": "desc" (and "sortIndex": 0, 1, ... across columns).
               Shift-click sorts by several columns; "alwaysMultiSort": true or "suppressMultiSort": true
               in dash_grid_options changes that.
  FILTERS      on by default ("filter": true). Name the filter that fits the column:
               "agTextColumnFilter", "agNumberColumnFilter", "agDateColumnFilter" ("agBigIntColumnFilter"
               for 64-bit ids). A date column shown with "format": "date" arrives as text (YYYY-MM-DD):
               give it "cellDataType": "dateString" with "filter": "agDateColumnFilter".
               "floatingFilter": true (per column, or in default_col_def) adds a filter row under the
               headers. "quickFilterText" in dash_grid_options filters every column at once.
  PINNING      "pinned": "left" | "right" keeps a column in view while scrolling sideways
               ("lockPinned": true stops people unpinning it).
  SIZING       "width" / "minWidth" / "maxWidth" in pixels, or "flex": 1 / 2 to share the free width;
               "resizable" is on by default. dash_grid_options "autoSizeStrategy":
               {"type": "fitGridWidth"} | {"type": "fitCellContents"} | {"type": "fitProvidedWidth", "width": 900}
               sizes columns when the grid loads (fitCellContents measures only the rows it has drawn).
  WRAP, HEIGHT "wrapText": true + "autoHeight": true lets long text (comments, descriptions) wrap and the
               row grow; "wrapHeaderText" + "autoHeaderHeight" do the same for headers.
  CELL STYLE   "cellClassRules": {"text-danger fw-semibold": "params.value < 0", "text-success": "params.value >= 0"}
               "cellStyle": {"styleConditions": [{"condition": "params.value == 'down'",
                             "style": {"color": "var(--bs-danger)", "fontWeight": 600}}]}
               Prefer classes (the theme's Bootstrap utilities: text-danger, text-warning, text-success,
               fw-semibold) over fixed colors, so dark and light themes both read.
  ROW STYLE    dash_grid_options "rowClassRules": {"text-danger": "params.data.status == 'down'"} colors a
               whole row (exceptions: wells down, SLA breaches).
  FORMAT       StrataBI's "format" on a column: integer, number[:n], currency[:n], percent[:n], ratio[:n],
               compact, date, datetime. Numeric formats right-align. Prefer it to hand-written
               valueFormatter functions.
  TOOLTIPS     "tooltipField": "<column>" shows another column's value on hover (a full comment behind a
               short one); "headerTooltip": "what this column means". dash_grid_options "tooltipShowDelay":
               500 (ms; default 2000), "tooltipShowMode": "whenTruncated" for cut-off text only.
  PAGINATION   on by default, "page_size" rows a page (default 25). The page-size picker defaults to
               20 / 50 / 100: give dash_grid_options "paginationPageSizeSelector": [25, 50, 100] (a list that
               includes page_size) or false to hide it. "pagination": false + a fixed "height" scrolls instead.
  Also Community: column groups ("children": [...] in a column definition), "headerName", cell text
  selection ("enableCellTextSelection": true), pinned rows from data the config carries
  ("pinnedBottomRowData"), CSV export through the tile's download button (artifact.download) rather
  than the grid.

2. ENTERPRISE: DOES NOTHING HERE, AND WHAT TO DO INSTEAD
  Row grouping (rowGroup, enableRowGroup, rowGroupPanelShow, groupDisplayType, autoGroupColumnDef,
    groupTotalRow, grandTotalRow) and aggregation (aggFunc, enableValue)
    -> GROUP BY in the SQL: one row per group with its totals; ROLLUP / GROUPING SETS for subtotal rows
       (label them with COALESCE); a total row as a KPI card or a second one-row query.
  Pivoting (pivotMode, pivot, enablePivot, pivotPanelShow)
    -> pivot in SQL (sum(CASE WHEN month = '2026-01' THEN x END) AS jan, ...), or a plotly heatmap
       (x = one dimension, y = the other, z = the value).
  Tree data (treeData) -> a parent column and a sort that keeps children under their parent; a plotly
    treemap / sunburst for the shape of a hierarchy.
  Set filter and multi filter ("filter": "agSetColumnFilter" / "agMultiColumnFilter")
    -> a page input: input_select (multi: true) bound into the query (region IN :regions), or the
       Text filter (its "contains" / "equals" options) on the column.
  Master / detail (masterDetail, detailCellRendererParams, "agGroupCellRenderer")
    -> a second table tile that re-runs on a selection input (triggered_by), or "wrapText" + "autoHeight"
       for a long text column.
  Excel export (excelStyles, defaultExcelExportParams)
    -> the tile's download button ("artifact": {"download": true}) gives the full result as a file.
  Range / cell selection, fill handle, clipboard (cellSelection, enableRangeSelection, enableFillHandle)
    -> "enableCellTextSelection": true lets people select and copy cell text.
  Integrated charts and sparklines (enableCharts, chartDataType, "agSparklineCellRenderer")
    -> a plotly tile beside the table, on the same query.
  Server-side and viewport row models (rowModelType "serverSide" / "viewport")
    -> aggregate or filter in SQL so the result fits max_rows; page inputs narrow the query.
  Also Enterprise: side bar and tool panels (sideBar), status bar (statusBar), context menu
    (getContextMenuItems), the column menu (mainMenuItems, "columnsMenuTab" / "generalMenuTab" in
    menuTabs), advanced filter (enableAdvancedFilter), find (findSearchValue), row numbers (rowNumbers),
    rich select editor ("agRichSelectCellEditor"). StrataBI's design lint warns on all of these
    (table.enterprise_option).

3. COMMON MISTAKES
  - An Enterprise option expecting a result (section 2): nothing happens; look at the browser console.
  - No column_defs: raw column names and unformatted numbers. Always headerName + format.
  - A field name containing a dot ("a.b") is read as a nested path and shows empty: alias it in SQL
    (AS a_b), or set "suppressFieldDotNotation": true in dash_grid_options.
  - "theme" in dash_grid_options: StrataBI's grid uses the legacy CSS themes ("theme": "legacy", set for
    you); setting another theme there stops className from applying. Change the look with className.
  - A table with no fixed height inside a growing card: keep "height" a CSS length ("420px"); the grid
    needs a height to lay out (domLayout "autoHeight" only for a handful of rows).
  - "filter": true on a date column formatted as text: dates sort and filter as text. Use
    "cellDataType": "dateString" + "agDateColumnFilter" (section 1).
  - A one-row table for headline numbers: make KPI cards (markdown template or a plotly indicator).
  - Rebuilding a table in raw_html to style it: cellClassRules, rowClassRules and format cover status
    colours and number formats, and keep sorting, filtering and download (design lint: raw_html.table).
  - Functions as JSON strings everywhere: only the expression props (cellClassRules, rowClassRules,
    styleConditions) and StrataBI's "format" are evaluated; other callbacks need Dash AG Grid's
    {"function": "..."} form, and a custom renderer needs a script the deployment ships.

4. PERFORMANCE
  - Every row of the result goes to the browser (client-side row model); pagination only pages what is
    already there. At most max_rows rows are sent (default 100,000, with a note when cut). Aggregate and
    filter in SQL: a table people read rarely needs more than a few thousand rows; a detail table gets
    ORDER BY + LIMIT.
  - Plain column definitions (field, headerName, format, sizing, sort and filter keys; no valueGetter,
    cellRenderer or column groups) let StrataBI load only those columns of a wide parquet result.
  - 5-8 columns. Keep column virtualisation on (do not set suppressColumnVirtualisation) for wide tables.
  - "autoHeight" makes the grid measure every row it draws: use it on the one column that needs it, with
    a modest page_size. "wrapText" alone (fixed row height) costs nothing.
  - Row animation is off (animateRows false); leave it off for tables that refresh on a timer.
  - Expressions in cellClassRules / rowClassRules run for every visible cell or row: keep them simple
    comparisons; compute categories (status, band) in SQL and style on the result.

Sources: AG Grid 35.3.1's own option-to-module validation tables and type definitions (ag-grid-community
35.3.1, MIT, https://www.ag-grid.com/archive/35.3.1/javascript-data-grid/community-vs-enterprise/), and Dash
AG Grid 35.3.0. Parts of COMMON MISTAKES are adapted from AG Grid's agent skills
(https://github.com/ag-grid/skills, skills/ag-dev/references/grid/recommendations.md), MIT License,
Copyright (c) 2015-2026 AG GRID LTD.
