Sorting is a core feature of Ginkelsoft DataTables and is enabled by default for all columns. This functionality cannot be disabled, ensuring that users always have the ability to organize their data effectively.
Clicking a column header will toggle between ascending and descending order.
Sorting applies to all columns specified in the :columns
array.
The default sorting column is id
, ordered in ascending (asc
) order.
The sorting state persists when navigating through paginated data.
Sorting is always active and does not require any additional configuration. However, you can define the default sorting behavior in your component:
<livewire:datatable
model="App\Models\User"
:columns="['id', 'name', 'email', 'created_at']"
:sort-column="'created_at'"
:sort-direction="'desc'"
/>
:sort-column
→ Defines the default sorting column (optional, default is id
).:sort-direction
→ Defines the default sorting direction (optional, default is asc
).
asc
).desc
).asc
).Sorting works automatically with the following setup:
<livewire:datatable
model="App\Models\User"
:columns="['id', 'name', 'email', 'created_at']"
/>
In this example, users can click on any column header to sort by that column in ascending or descending order.
Sorting cannot be disabled.
Sorting applies to all columns in the :columns
array.
The initial sort order can be set using :sort-column
and :sort-direction
.
Sorting ensures that data remains structured and easy to navigate for users at all times.