Skip to content

Table API

Create a builder with InertiaX::table(string $id) or YourTable::make(string $id). The facade is InertiaX\Facades\InertiaX; reusable classes extend InertiaX\Components\Table\Table. Fluent methods below return the builder.

Method Contract
make(string $id) ID is 1–64 characters, starting with an ASCII letter, followed by letters, digits, _, or -; also names the Inertia prop
data(Builder|Collection|array|string|Closure $data) Eloquent builder, Laravel/Eloquent collection, array, Eloquent model class, or closure returning one of those
rowKey(string $key) Override the field used to identify rows

In a subclass, protected function data(): mixed, protected function columns(): array, and protected function filters(): array declare the source and definitions. See Inheritance for precedence.

Columns Filters Effect
addColumn($column, ?string $label = null, $transformer = null) addFilter($filter, ?string $label = null) Add a new key; duplicate keys fail
addColumns(array $columns) addFilters(array $filters) Add each entry
replaceColumn($column, ?string $label = null, $transformer = null) replaceFilter($filter, ?string $label = null) Replace an existing key in place; missing keys fail
replaceColumns(array $columns) replaceFilters(array $filters) Replace each entry
removeColumn($column) removeFilter($filter) Remove an existing key; missing keys fail
removeColumns(array $columns) removeFilters(array $filters) Remove each entry
clearColumns() clearFilters() Remove all explicit entries
setColumns(array $columns) setFilters(array $filters) Clear, then add; duplicate validation still applies
autoColumns(bool $enabled = true) autoFilters(bool $enabled = true) Enable inference after explicit definitions

Column entries accept column objects, builders, or field-key strings; strings use TextColumn. The optional transformer accepts a closure, a ValueTransformer instance, or its class name. Filter entries accept filter objects, builders, or field-key strings; strings use TextFilter. Plural add/replace methods also accept entries with key and optional label; column entries may include transformer.

Automatic columns skip existing keys but can reintroduce eligible keys removed from the explicit list. Automatic filters fill undeclared filterable keys. Disable inference when the explicit list must be exhaustive.

Method Accepted value
pagination(bool $enabled = true) Enable page controls and server pagination
pageSize(int $size) Positive default page size
pageSizeOptions(array $sizes) Nonempty array of positive integers
sorting(bool $enabled = true) Enable sorting
multiSort(bool $enabled = true) Permit multiple sort entries
initialSort(string|array $sorting) A key, -key, or ordered {key, direction} entries
selection(bool $enabled = true) Enable row selection
selectionMode(SelectionMode|string $mode) single or multiple
filterMode(FilterMode|string $mode) basic or advanced
refreshButton(bool $enabled = true) Show the refresh button

The enums live in InertiaX\Components\Table\Enums. Invalid backed strings fail immediately. Protected class defaults for these modes are enum-typed. See Defaults.

These accept a Boolean, defaulting to true: sortableColumns(), searchableColumns(), filterableColumns(), copyableColumns(), toggleableColumns(), visibleColumns(), and wrapColumns(). truncateColumns(?int $length) sets truncation; 0 disables it. Passing null or calling clearTruncateColumns() removes the fluent override and restores the class default. Explicit options on a column take precedence.

searchableColumns() requires every resulting column to be text or have its own search strategy.

These static methods apply to the target table class and its descendants. Configure them during application boot, before the first table execution.

Columns Filters Arguments
registerColumn() registerFilter() mixed $definition, int $priority = 10, ?string $name = null
replaceRegisteredColumn() replaceRegisteredFilter() Same; replacement requires an existing definition at composition time
unregisterColumnByKey() unregisterFilterByKey() string $key
unregisterColumn() unregisterFilter() callable $predicate
unregisterColumnRegistration() unregisterFilterRegistration() string $name
unregisterColumnReplacementByKey() unregisterFilterReplacementByKey() string $key
unregisterColumnReplacement() unregisterFilterReplacement() string $name
inspectColumnRegistrations() inspectFilterRegistrations() No arguments; returns registration descriptions

Use unique registration names within a scope. Lower priorities run first; equal priorities use registration order. Duplicate registrations and removals without a match fail. See Module contributions for precedence.

Eloquent builders use the model’s primary key. Collections use the first model’s primary key when one is available; otherwise they use id. An explicit rowKey() wins in both cases.

The row-key field must be a declared column even for an empty result. Returned keys must be unique strings or JavaScript-safe integers. Keep identifiers unique across the dataset, not just a page. PHP integers outside JavaScript’s safe range are transported as exact decimal strings. Values too large for PHP integers must enter the source as strings to avoid precision loss.

Search trims the term and permits at most 500 Unicode code points. Built-in text search is a case-insensitive substring match combined with or across searchable columns. Filters run first and still constrain the result. Non-text columns require searchUsing().

Database collations and Unicode case handling can differ from collection string comparisons. Check your database and languages when the distinction matters.

Sort entries are ordered, unique {key, direction} pairs. Directions are asc or desc; keys must identify sortable columns. Multiple entries require multi-sort to be enabled. When an active sort omits the row key, InertiaX adds an ascending row-key tie-breaker. Built-in SQL ordering qualifies physical column names for joins.

Existing query ordering is preserved, not cleared or reinterpreted. Use an unordered base query for interactive sorting, or sorting(false) for a fixed query order.

Page and page size must be positive integers. Page-size choices are deduplicated and sorted; the default page size is added if absent. Requests must use one of those choices.

An empty result has last page 1. A page beyond the last page fails rather than silently clamping. When pagination is disabled, the whole processed result is returned and incoming pagination parameters are rejected.

Execution order is filters → search → sorting → pagination → cell serialization. Request timing and client-state reconciliation are documented in Request lifecycle.