Sorting
Sorting is managed automatically by SortPipe. This allows users to click the header on the table interface to sort the data (Ascending or Descending).
Enabling Sorting
Section titled “Enabling Sorting”Similar to the search feature, you must explicitly allow columns to be sorted using the sortable() method.
use Kinetics\Table;use Kinetics\Columns\TextColumn;
$table = Table::model(Product::class) ->columns([ TextColumn::make('name')->sortable(), TextColumn::make('price')->sortable(), TextColumn::make('created_at')->label('Created Date')->sortable(), ]) ->make();When you enable sortable(), the <Table /> frontend component will render that header as an interactive clickable element.
How SortPipe Works
Section titled “How SortPipe Works”SortPipewill check the request parameters to see if there is a sorting request (e.g.,?sort=price&direction=desc).- It then validates whether the
pricecolumn is actually declared withsortable(). If not, the sort request is ignored (preventing client-side query manipulation). - If valid, it adds an
ORDER BY price DESCclause into your Eloquent query builder.
This ensures that all sorted and paginated data is always processed on the database side.