Sorting & Defaults

Make any column sortable and keep related records together with a default sort applied before user interaction.

$this->setDefaultSort('active', 'desc') // v3 has no groupBy()

Not available in v3

Row grouping is a v4-only feature. Version 3 has no grouping subsystem at all — there is no groupBy(), no groupsExpanded()/groupsCollapsed(), and no group headers or per-group row counts. The live demo below therefore renders a plain table with a default sort on the column that would have been the grouping column, so related rows still appear together.

Example Usage GroupingDemoTable.php
public function configure(): void
{
    $this->setPrimaryKey('id')
        // groupBy() / groupsExpanded() do not exist in v3.
        ->setDefaultSort('active', 'desc');   // Closest v3 equivalent
}

public function columns(): array
{
    return [
        Column::make('ID', 'id')->sortable(),
        Column::make('Name', 'name')->sortable()->searchable(),
        Column::make('Email', 'email')->sortable()->searchable(),
        BooleanColumn::make('Active', 'active')->sortable(),
    ];
}
Visual Group Headers
Click to expand/collapse
Collapsible Groups
groupsCollapsed()
Row Counts
Shows items per group

True Row Grouping (v4 only)

In v4, row grouping creates visual group headers that organize rows by a common value. Each group shows a header with the group label and row count, and the header can be clicked to expand or collapse the group. None of this exists in v3 — the feature cards above describe v4 behaviour only.

Active: true (12 items) → Group header with expand/collapse

Live Demo

Users sorted by Active status (v3 has no group headers to expand/collapse)

Applied Sorting: Active: Z-A
1 Miss Eve Will [email protected] 97%
2 Mr. Cornelius Hansen DDS [email protected] 17%
3 Dr. Albertha Abbott [email protected] 70%
4 Citlalli Berge PhD [email protected] 26%
5 Mr. Austen Harber [email protected] 35%
6 Raegan Pfannerstill PhD [email protected] 60%
7 Dan Ebert [email protected] 21%
8 Mertie Kohler [email protected] 56%
9 Prof. Cornelius Herzog DDS [email protected] 41%
10 Barbara Metz [email protected] 37%
11 Katelin Dickinson [email protected] 57%
12 Cindy Corwin [email protected] 19%
13 Dagmar Gislason [email protected] 39%
14 Frieda Ebert I [email protected] 94%
15 Braulio Brakus [email protected] 18%
16 Prof. Ollie Dooley III [email protected] 80%
17 Mr. Jamal Littel DVM [email protected] 48%
18 Retha Streich III [email protected] 18%
19 Dr. Carson Hudson [email protected] 58%
20 Trystan Lowe [email protected] 60%
21 Dorothea Durgan [email protected] 13%
22 Vesta Robel [email protected] 95%
23 Mrs. Leora Swaniawski V [email protected] 4%
24 Dane Pouros DDS [email protected] 59%
25 Kraig Bruen [email protected] 11%

Showing 1 to 25 of results