Skip to content

Server protocols ​

A server-side grid sends one request per page, sort, search or filter change. What that request and its response look like is the protocol. datagrids speaks three, all through the same serverSide() source:

js
import { Datagrid, serverSide, yajra } from "@akinozgen17/datagrids";

new Datagrid("#agents", {
  label: "Agents",
  columns,
  use: [serverSide({ url: "/agents/data", protocol: yajra(), csrf: true })],
});

Which one? ​

You have…UsePage
An endpoint written for DataTables' server-side processing, in any languagessp()SSP wire
A Laravel endpoint built with yajra/laravel-datatablesyajra()SSP wire
A Laravel endpoint returning paginate(), simplePaginate(), cursorPaginate() or an API resource collectionlaravelPaginator()Laravel paginator
A new endpoint, or one you are free to changedgp()datagrids protocol v1

Keep an existing endpoint as it is: the SSP and paginator adapters exist so that you can move the front end first and touch the back end later (or never). For new endpoints, prefer the datagrids protocol: sorting by key, typed filters, optional counting and one error format.

How they differ ​

ssp() / yajra()laravelPaginator()dgp()
Methodssp: GET + _= timestamp; yajra: POST form bodyGETPOST JSON (GET optional)
Untyped cellsssp: text; yajra: HTML (yajra escapes values)texttext
Sortcolumn index, several keysfirst key only (sort=-date)key, several keys
Searchsearch[value]searchq
Page filtersplain parametersplain parametersparams
Typed column filterscolumns[i][columnControl] (no between, notIn)value only (operator dropped)filters, 15 operators
Countingalwayspaginate(): yes; simple and cursor: next page onlyexact, estimate or none
"All" (length=-1)opt-in (allowAll: true)nono
ErrorsHTTP status, or error in a 200HTTP statusRFC 9457 problem details
Side dataextra top-level keysmeta, linksmeta.aggregates, facets, warnings

"Untyped cells" are columns without a type: plain { key, title } objects. Typed columns (column.text(), column.money(), column.date(), column.badge()…) always render the same way, whatever the protocol. Cells are text by default; HTML is an explicit opt-in (column.html()), and yajra() is the one protocol whose untyped cells are HTML, because yajra escapes every non-raw value on the server.

What every protocol shares ​

These come from serverSide(), not from the protocol:

OptionDefaultWhat it does
urlrequiredEndpoint. A function (query) => url builds it per request
protocolrequiredssp(), yajra(), laravelPaginator() or dgp()
methodthe protocol'sOverrides the method ("GET" or "POST")
csrfconfigure({ csrf }), else falseReads <meta name="csrf-token">: X-CSRF-TOKEN header, plus _token in non-GET bodies
paramsnoneExtra request parameters: an object, or a function of the query called per request
headersnoneExtra request headers
timeout30000 msAborts the request and shows the timeout error
seednoneA response body rendered as the first page without a request (server-rendered first page)
fetchglobalThis.fetchCustom transport

And on every request:

  • Headers: X-Requested-With: XMLHttpRequest (turn it off with configure({ laravel: false })) and an Accept header that fits the protocol. Cookies are sent (credentials: "same-origin").
  • Last request wins: a new request aborts the previous one, and responses are matched to requests by an internal sequence number, never by draw or requestId.
  • Debug keys: queries and input members (Laravel debug output, which can hold SQL and personal data) are deleted from the response before any event, module or lastResponse() sees it.
  • Errors: every failure becomes one DatagridError with a kind, a user-safe message and a retryable flag. See the error table.
  • Session expiry: 401, 419 and redirects to a login page fire the sessionexpired event.

Released under the MIT License.