datatable-pagination

Implements server-paginated DataTable components in Nuxt with sorting, per-page persistence, and API pagination contracts.

Updated May 5, 2025
One-click install
npx skills add https://github.com/sebauvray/toollab-api --skill datatable-pagination-sebauvray
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: datatable-pagination
Source: https://github.com/sebauvray/toollab-api/tree/main/.claude/skills/datatable-pagination
Command: npx skills add https://github.com/sebauvray/toollab-api --skill datatable-pagination-sebauvray

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building paginated list views in the Toollab Nuxt/Laravel stack involves subtle pitfalls: header/row grid misalignment, per-page selectors that do nothing, SSR-unsafe localStorage access, and client-side filtering that only filters the current page. This Skill encodes the full front-to-API pagination contract so lists are built correctly the first time. ## Core Features & Use Cases - End-to-end pagination contract: Defines the API response shape (snake_case pagination object) and its conversion to the camelCase format the DataTable component expects, done in the page. - Standard page pattern: Provides a complete Vue page template wiring DataTable with sorting, debounced search, page changes, and per-page changes, including the useTablePerPage composable for persisting page size in localStorage. - Server-side rules: Documents the Laravel pagination conventions (default 10, cap 100, lower-bound guard), when in-memory filtering is acceptable, and the one-row-per-entity rule. - Use Case: When adding a new admin list page (e.g., a paginated table of families with sortable columns and a status filter), invoke this Skill to generate the page, wire all DataTable events, and add the matching paginated API endpoint without the documented pitfalls. ## Quick Start Create a new paginated list page for the Toollab admin showing items with sortable columns, server-side search, and a per-page selector following the datatable-pagination conventions.

Frequently Asked Questions about datatable-pagination

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a paginated table in Nuxt with server-side sorting?▼

Use the DataTable component with columns, items, pagination, loading, and sort props, and wire the page-change, per-page-change, and sort-change events to a fetch function that sends page, per_page, sort_by, and sort_direction as query parameters to the API.

How do I persist the per-page selection across page reloads in Nuxt?▼

Use the useTablePerPage composable with a unique storage key. Call loadPerPage inside onMounted before the first fetch, never at setup level, because localStorage is unavailable during SSR. Call savePerPage when the user changes the page size.

Why are my DataTable header and rows misaligned?▼

The sum of column width values defines the header grid-template-columns, while custom row templates redefine it inline. Both must use the same 12-column distribution, otherwise headers and rows render with different column widths.

Should I filter paginated data on the client or the server?▼

Filter on the server by sending filter parameters in the API request. Client-side filtering of server-paginated data only filters the current page, producing incomplete and misleading results.

What per_page limits should a Laravel pagination endpoint enforce?▼

Default to 10 and cap at 100 using max(1, min((int) per_page, 100)). Without a lower bound, per_page=0 causes a division by zero in the total pages calculation and returns a 500 error.