Sorting & pagination
Sorting and pagination are handled for you once a column opts in and a mode is chosen. The table sends the current sort and page to its endpoint, and the data source applies them.
TextColumn::make('name')->label('Name')->sortable()->filterable();NumberColumn::make('price')->label('Price')->sortable()->filterable();BooleanColumn::make('featured')->label('Featured')->filterable();TextColumn::make('updated_at')->label('Updated')->dateTime()->sortable();- actionsLabel:null
- bulkActions:[]
- data:[{"featured":true,"name":"Desk Lamp","price":"49.00","updated_at":"2026-05-30 09:15:00"},{"featured":false,"name":"Office Chair","price":"189.00","updated_at":"2026-06-02 14:40:00"},{"featured":true,"name":"Monitor Stand","price":"75.50","updated_at":"2026-06-08 08:05:00"}]
- emptyLabel:null
- endpoint:null
- filters:[]
- layout:null
- lazy:false
- pagination:{"currentPage":null,"from":1,"hasMore":false,"lastPage":null,"mode":"none","nextPage":null,"perPage":null,"to":3,"total":3}
- perPageOptions:[]
- pinnableColumns:false
- query:{"filters":[],"mode":null,"page":1,"perPage":25,"search":"","sorts":[],"tableFilterIndicators":[],"tableFilters":{}}
- resizableColumns:false
- resizeIndicator:false
- searchable:false
- striped:false
- toolbar:[]
- align:"start"
- badge:null
- copyable:false
- date:null
- hiddenByDefault:false
- label:"Name"
- link:null
- multiple:null
- options:[]
- pinned:null
- sortable:true
- toggleable:false
- width:"md"
- align:"end"
- compact:false
- copyable:false
- hiddenByDefault:false
- label:"Price"
- maximumFractionDigits:null
- minimumFractionDigits:null
- options:[]
- pinned:null
- sortable:true
- toggleable:false
- unit:null
- width:"md"
- align:"start"
- hiddenByDefault:false
- label:"Featured"
- options:[]
- pinned:null
- sortable:false
- toggleable:false
- width:"md"
- align:"start"
- badge:null
- copyable:false
- date:{"dateStyle":"medium","timeStyle":"medium"}
- filter:null
- hiddenByDefault:false
- label:"Updated"
- link:null
- multiple:null
- options:[]
- pinned:null
- sortable:true
- toggleable:false
- width:"md"
Sorting
Section titled “Sorting”->sortable() adds the sort control to a column header. Clicking it cycles ascending, descending, and
off, and the source applies an orderBy on the column key. Several columns can be sortable at once.
TextColumn::make('name')->sortable();Sorting is keyed by the column key, so a sortable column must map to a real database column — or a to-one relation field, which sorts through a correlated subquery. Set a default order in the builder for when the user hasn’t chosen one.
Pagination
Section titled “Pagination”Override pagination() to choose how rows are paged, and perPage() for the page size. The mode is a
PaginationType:
| Mode | Behavior |
|---|---|
PaginationType::Table |
Full pager with page numbers and total (the default). |
PaginationType::Simple |
Previous / next only — cheaper, no total count. |
PaginationType::Infinite |
Loads the next page as the user scrolls. |
PaginationType::None |
Returns every row, no pagination. |
use Lattice\Table\Enums\PaginationType;
public function pagination(): PaginationType{ return PaginationType::Simple;}
public function perPage(): int{ return 50;}A custom data source chooses its own TableResult builder to match the mode —
fromPaginator() for a full pager, fromSimplePaginator() for infinite scroll-to-load, or
fromSimplePaginator($paginator, PaginationType::Simple) for previous/next. The
Eloquent source picks the right one from the mode automatically.
Page size options
Section titled “Page size options”Declare perPageOptions() to render a page-size select in the pagination bar. Numeric entries offer
fixed page sizes; PaginationType::Infinite lets the user switch the table to infinite pagination on
the fly — and back to numbered pages.
use Lattice\Table\Enums\PaginationType;
public function perPageOptions(): array{ return [10, 25, 50, 100, PaginationType::Infinite];}The endpoint accepts only declared sizes and falls back to perPage() for anything else. Tables
without options keep their fixed page size and mode.