contao-components/tristen-tablesort
Contao integration of Tristen’s TableSort JavaScript, adding client-side sorting to HTML tables in Contao projects. Lightweight and easy to include, enabling click-to-sort column headers without server-side changes.
tristen-tablesort package provides client-side table sorting functionality, which is a common requirement for data-heavy applications (e.g., admin dashboards, reporting tools, or user-facing tables). It aligns well with Laravel applications where server-side pagination (e.g., via Laravel Scout, Eloquent, or custom queries) is already implemented but lacks client-side sorting UX.tristen-tablesort). Works with vanilla JS or modern frameworks (Vue, React, Alpine.js) if wrapped in a component.<table> with specific class/ID attributes). Limited documentation may necessitate reverse-engineering or testing edge cases.route('api.data')), the package can trigger server-side sorting via query parameters (e.g., ?sort=column&order=asc). This requires minimal backend changes (e.g., handling sort/order params in a controller).sort/order query parameters?npm install tristen-tablesort) and initialize in a Blade template or JS file.TableSort.vue).GET /api/data) that accepts sort and order params and returns sorted data (e.g., via Eloquent queries or raw SQL).<table class="tablesort">).new Tablesort(document.querySelector('.tablesort'));
sortchange) when columns are sorted.document.querySelector('.tablesort').addEventListener('sortchange', (e) => {
fetch(`/api/data?sort=${e.detail.column}&order=${e.detail.order}`);
});
sort/order params:
public function getData(Request $request) {
$query = Model::query();
if ($request->has('sort') && $request->has('order')) {
$query->orderBy($request->sort, $request->order);
}
return $query->get();
}
Route::get('/api/data', [DataController::class, 'getData']);
dd() or Log::debug).How can I help you explore Laravel packages today?