Block Attributes Reference

The TableCrafter Gutenberg block tablecrafter/data-table exposes 14 saved attributes that control its data source, column visibility, search, filtering, export, pagination, and live auto-refresh behavior. This page documents every attribute as registered in register_block_type() and the editor's registerBlockType() call.

Gutenberg Block Editor Dynamic Block Server-Side Render Auto-Refresh

Overview

TableCrafter ships a single native block, registered as tablecrafter/data-table under the Widgets category. It is a dynamic block: the editor save function returns null, and all frontend markup is produced server-side by the PHP render_block_callback(), which forwards the attributes straight into the same engine that powers the [tablecrafter] shortcode. The block is registered on the WordPress init hook, so its attributes are available everywhere the editor and REST API run.

Insert the block from the editor inserter (search for "TableCrafter"), then configure every attribute visually through the sidebar (Inspector Controls). You do not edit attribute JSON by hand in normal use, but understanding the names is essential for theme integration, programmatic block insertion, and pattern building.

ℹ️

Every block attribute below has an exact one-to-one counterpart in the [tablecrafter] shortcode, with one exception: the shortcode also accepts a sort attribute that the block does not register. If you need initial sort order, use the shortcode instead.

How attributes are stored and rendered

Attributes are persisted in the block's comment delimiter inside post content. On render, WordPress passes the attribute array to the PHP callback:

// register_block_type('tablecrafter/data-table', ...) render_callback
public function render_block_callback($attributes): string {
    if (empty($attributes['id'])) {
        $attributes['id'] = 'tc-block-' . uniqid();
    }
    return $this->render_table($attributes);
}

The callback injects every value into the front-end container as a data-* attribute (for example source becomes data-source, per_page becomes data-per-page, auto_refresh becomes data-auto-refresh). The bundled JavaScript reads those attributes to build the interactive table.

Core attributes

These attributes define what data is loaded and which columns appear.

AttributeTypeDefaultRequiredDescription
sourcestring''RequiredURL to the data source: a JSON API, CSV file, or published Google Sheet. Must be publicly accessible. With no source the block renders an empty-source placeholder.
rootstring''OptionalDot-notation path to the data array inside a nested JSON response (for example data.items or response.results). Leave blank for flat top-level arrays.
includestring''OptionalComma-separated allowlist of field names to display (for example name,email,status). When set, only these columns render.
excludestring''OptionalComma-separated list of field names to hide (for example id,password,internal_notes).
idstring''OptionalDOM id for the table container. If empty, the render callback auto-generates one in the form tc-block-{uniqid}.
⚠️

Setting both include and exclude at once is redundant. Pick one strategy: an allowlist with include, or a denylist with exclude.

Interactivity attributes

These toggles control the user-facing table controls. They are booleans in both the block registration and the editor; the PHP shortcode bridge also accepts the strings true, 1, and yes as truthy.

AttributeTypeDefaultRequiredDescription
searchbooleanfalseOptionalAdds a real-time global search bar that filters all rows as the user types.
filtersbooleantrueOptionalAdds per-column filters: dropdowns for text, ranges for numbers, and date pickers for dates. Enabled by default.
exportbooleanfalseOptionalAdds CSV download and copy-to-clipboard buttons that respect the current search and filter state.
per_pagenumber0OptionalRows per page. 0 shows all rows (pagination off). Any value greater than 0 enables pagination at that page size; 10–50 is recommended for large datasets.

Auto-refresh attributes

Auto-refresh turns a static table into a live dashboard that re-fetches data on an interval. The four sub-options below only take effect when auto_refresh is enabled — the editor's "Auto-Refresh Settings" panel hides them until the master toggle is on.

AttributeTypeDefaultRequiredDescription
auto_refreshbooleanfalseOptionalMaster switch. When on, the table automatically fetches fresh data at the configured interval.
refresh_intervalnumber300000OptionalRefresh frequency in milliseconds. Defaults to 300000 (5 minutes). Reference points: 30000 = 30s, 300000 = 5min, 3600000 = 1hr.
refresh_indicatorbooleantrueOptionalShows the visual refresh controls: a spinning icon plus pause/resume and manual-refresh buttons.
refresh_countdownbooleanfalseOptionalDisplays a live countdown to the next automatic refresh.
refresh_last_updatedbooleantrueOptionalShows a "last updated" timestamp (for example "Updated 3 minutes ago") so users can gauge data freshness.
💡

The underlying engine adds resilience automatically when auto-refresh is on: it pauses while the user is interacting, pauses when the browser tab is hidden, and retries failed fetches up to 3 times.

Configuring attributes in the editor

Each attribute maps to a sidebar control under Settings → Block when the TableCrafter block is selected:

The block renders a live, server-side preview inside the editor via wp-server-side-render, so changing a sidebar control re-renders the actual table rather than a placeholder.

Equivalent shortcode

Because the block and the [tablecrafter] shortcode share the same render engine, any block configuration can be expressed as a shortcode. A block with search, export, pagination, and auto-refresh enabled is equivalent to:

[tablecrafter
  source="https://example.com/api/employees.json"
  root="data.items"
  include="name,email,department,status"
  search="true"
  filters="true"
  export="true"
  per_page=25
  auto_refresh="true"
  refresh_interval=60000
  refresh_countdown="true"]

The matching block markup stored in post content looks like this:

<!-- wp:tablecrafter/data-table {
  "source":"https://example.com/api/employees.json",
  "root":"data.items",
  "include":"name,email,department,status",
  "search":true,"export":true,"per_page":25,
  "auto_refresh":true,"refresh_interval":60000,"refresh_countdown":true
} /-->
ℹ️

Attributes left at their default value are omitted from the saved block JSON. For example, filters defaults to true, so you will only see "filters":false written out when you explicitly disable column filters.

Notes and edge cases

Next steps

For the full attribute set including sort and string-based booleans, see shortcode-reference.html. To learn how nested JSON, CSV, and Google Sheets sources are parsed before rendering, continue to data-sources.html.