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();NumberColumn::make('price')->label('Price')->sortable();TextColumn::make('updated_at')->label('Updated')->dateTime()->sortable();- actionsLabel:"Actions"
- 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:"No results"
- endpoint:null
- filters:[]
- layout:null
- lazy:null
- pagination:{"currentPage":null,"from":1,"hasMore":false,"lastPage":null,"mode":"none","nextPage":null,"perPage":null,"to":3,"total":3}
- resizableColumns:null
- resizeIndicator:false
- state:{"filters":[],"page":1,"perPage":25,"sorts":[],"tableFilters":[]}
- striped:true
- badge:null
- copyable:false
- date:null
- link:null
- multiple:null
- compact:false
- maximumFractionDigits:null
- minimumFractionDigits:null
- unit:null
- badge:null
- copyable:false
- date:{"dateStyle":"medium","timeStyle":"medium"}
- link:null
- multiple:null
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\Lattice\Tables\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 previous/next. The
Eloquent source picks the right one from the mode automatically.