3.3.1 • Published 1 month ago

@matco/basic-table v3.3.1

Weekly downloads
4
License
Unlicense
Repository
github
Last release
1 month ago

basic-table

basic-table displays your tabular data in a nice HTML table.

Setup

Manual

Copy the src folder as basic-table somewhere in your project.

Then, in your code:

import {Table, Datasource} from 'basic-table/index.js';

With NPM and Webpack

The instructions below are for those who are using NPM and Webpack.

Install as an NPM dependency of your project:

npm i @matco/basic-table --save

Then, in your code:

import {Table, Datasource} from '@matco/basic-table';

Usage

function render_name(value, record) {
	const link = document.createElement('a');
	link.setAttribute('href', `#id=${record.id}`);
	link.appendChild(document.createTextNode(value));
	return link;
}

function render_date(value) {
	return value.toDisplay();
}

new Table({
	container: document.getElementById('table'),
	columns: [
		{label: 'Country', data: 'country', type: Table.DataType.STRING, width: 250},
		{label: 'Name', data: 'name', type: Table.DataType.STRING, render: render_name, width: 200},
		{label: 'Date', data: 'date', type: Table.DataType.DATE, render: render_date, width: 120},
		{label: 'IBAN', data: 'iban', type: Table.DataType.STRING},
		{label: 'Value', data: 'value', type: Table.DataType.NUMBER, width: 120}
	],
	actions: [
		{label: 'Export', url: '#export'}
	]
}).render(new Datasource({url: 'data.json'}));

Example

If you want to see some examples, checkout example/index.js.

Development

The instructions below are for developers.

Example page

To manually test the project using the example page, run:

npm start

This will launch a Webpack development server on port 9000.

Lint & Check

You can lint and check the code of the project with the following commands:

npm run lint
npm run tsc

Test

To test the application, run:

npm test
3.3.1

1 month ago

3.3.0

5 months ago

3.2.0

11 months ago

3.1.0

1 year ago

3.0.0

2 years ago

2.1.0

3 years ago

2.0.0

3 years ago

1.1.0

4 years ago

1.0.0

4 years ago