0.1.0 • Published 4 years ago

usfca-data-table v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

A lightweight HTML+JS library for inputting two-dimensional form data

See this project at https://brmighell.github.io/rcv-entry/

Coverage Status

A lightweight, extendable, dependency-free javascript HTML table plugin

The default configuration:

Features & Benefits

Features:

  • Customisable labels
  • Customisable layout
  • Customise column rendering
  • Has option to disable any input type for any cell
  • Has option to change values for any input type at any cell
  • Callback informs RCVis of the updates

Benefits:

  • Vanilla Javascript & CSS
  • No external libraries: no jQuery, bootstrap, Sass, etc
  • Simple javascript configuration with sane defaults
  • Simple, easy-to-override CSS
  • Permissive license

Examples

#1: Default

#2: Fruit Example

Usage

API: Vanilla Javascript

If you're not using node.js, functions begin with dt namespace to avoid conflicts:

Include the files in your HTML and create a wrapper div:

<link rel="stylesheet" href="table.css">
<script type="text/javascript" src="table.js"></script>
<div id="table"></div>

Create a table by calling:

const config = {wrapperDivId: 'div'}
dtCreateDataTable(config);

additional config options are described below.

Callbacks and data validation

Each field can optionally trigger a callback when it is edited. Callback functions should return null or nothing (undefined) if there is no error, and return an error message (string) if there is an error.

Configuration options

The config dictionary has the following options:

key/defaultdescription
wrapperDivId* requiredThe div id in which to create the data table.
numRows default: 3Number of rows in the table.
numColumns default: 4Number of columns in the table.
rowsName default: RowName of rows in the table.
columnsName default: ColumnName of columns in the table.
canEditRowHeader default: trueMake the row headers an input field?
canEditColumnHeader default: falseMake the column headers an input field?
names default: ["Value", "Status"]Array of the names for all fields in a cell.
types default: [Number, Array]Array of the types for all fields in a cell.
values default: [0, ["Active", "Inactive"]]Array of the types for all fields in a cell.
callbacks default: "None"Tells what function to execute when a field is changed.

CSS configuration

All CSS styles begin with dt_ and can be overridden with your own custom CSS. See data-table/table.css for some of the options that may be overridden. Additional, unstyled classes are also set on several elements, though these are undocumented.

0.1.0

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago