Skip to content

philc/datatable.js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Datatable.js - a minimal HTML data table for presenting tabular data

A data table is a sortable HTML table which displays tabular data.

This is a simpler, tailored implementation of the UX provided by datatables.net, and is primarily used for building interactive dashboards.

Example usage

import * as dt from "./datatable.js";

// Row data will typically come from a database. These row objects should be in the form:
// { col1: val1, col2: val2 }.
const rows = [];
for (let i = 1; i <= 10; i++) {
  rows.push({ name: "Sample product " + i, views: i* 10, purchases: i, revenue: i * 9.99 });
}

const table = new dt.DataTable({
  columnNames: { id: "ID" },
  sort: { column: "views", order: "asc" },
  formatters: { revenue: dt.formatters.currency }
});

table.renderRows(rows);
document.body.appendChild(table.el);

// Optional events.
table.addEventListener("cellClick", (event) => ...);
table.addEventListener("sortChange", (event) => ...);

License

Licensed under the MIT license.

About

A minimal HTML data table for presenting tabular data

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published