Skip to content

datagridsData grids for plain HTML tables

Zero dependencies. A design your page's CSS can't break. Native-table accessibility. Typed columns and small composable modules. Talks to your server the way it already works.

See it working ​

A server-side grid with a column menu, saved view, reload button and export menu. The server runs inside this page; the Request tab shows exactly what goes over the wire.

js
import { Datagrid, column, serverSide, yajra, colVis, stateSave, button, excel, csv, print } from "@akinozgen17/datagrids";
import { statusLabels, statusTones } from "./data.js";

new Datagrid("#home-grid", {
  label: "Field agents",
  columns: [
    // plain columns follow the protocol: yajra escapes strings on the server, so they render as HTML
    { key: "ref", title: "Ref" },
    { key: "name", title: "Name" },
    { key: "unit", title: "Unit" },
    { key: "task", title: "Task", visible: false },
    column.badge("status", { title: "Status", labels: statusLabels, tones: statusTones }),
    column.money("amount", { title: "Amount", currency: "USD", locale: "en-US" }),
    column.date("date", { title: "Date", time: true }),
  ],
  sort: [["date", "desc"]],
  pageSize: 10,
  count: true,
  use: [
    serverSide({ url: "/api/agents", protocol: yajra(), csrf: true }),
    colVis(),
    button.reload(),
    stateSave(),
    excel(),
    csv(),
    print(),
  ],
});
html
<table id="home-grid"></table>

Install ​

sh
npm i @akinozgen17/datagrids
js
import { Datagrid, column, serverSide, yajra } from "@akinozgen17/datagrids";
import "@akinozgen17/datagrids/css";

Then read Getting started and Concepts. Moving an existing grid over? The migration guide maps options, events and API calls one by one.

Released under the MIT License.