Lightweight and easy to use data table
Import the element in the head
<script src="./table-of-data.js">
Put the element somewhere in the body
<table-of-data></table-of-data>
Put data in the table
let data = {
headings: [ 'State', 'Place' ],
rows: [
[ 'California',
'Redwood Forest'
],
[ 'New York',
'New York Islands'
]
]
};
document.querySelector('table-of-data').data = data;
Only Custom Elements needs to be polyfilled (custom-elements.js
). To see how to use a polyfill, check out index.html, which only loads the polyfill if needed (credit to Eric Bidelman).