Table Grid Component/Widget in ES6. Pure Javascript. That uncut sht.*
Size (gzipped/minified): 4Kb/12Kb
- Table Grid Component/Widget.
- Scrollable
- Sortable
- Selectable
- Universal Javascript
- Universal Module - UMD/AMD/CJS
- With core css embedded
- Easy to style (more examples will be added)
- Small, performant and extensible (see plugins folder)
npm install
npm run build
2 features are implemented with a plugin interface:
- Selection
- Sortable
Selection is enabled by setting the following option {selection: true}
Rows become selectable, add a checkbox column where to the columns like this:
const config = {
columns: [
{selection: true, multiple: true, toggleAll: true, classes: ['text-center', 'tbl-xs-2']},
{title: 'Name', render: 'name', cols: 4}
]
}
Sortable is enabled by setting the following option {sortable: true}
Rows become selectable, add a checkbox column where to the columns like this:
const config = {
columns: [
{selection: true, multiple: true, toggleAll: true, classes: ['text-center', 'tbl-xs-2']},
{title: 'Name', render: 'name', cols: 4}
]
}
const config = {
selectable: true,
sortable: true,
defaultSort: 'name',
columns: [
{selection: true, multiple: true, toggleAll: true, classes: ['text-center', 'tbl-xs-2']},
{title: 'Name', render: 'name', cols: 4},
{title: 'Number', render: 'number'},
{title: 'Region', render: 'region'},
{title: 'Type', sort: 'type', render: ({row}) => row.type && row.type.toLowerCase() || 'N/A'},
],
data: Promise.resolve(data)
};
function init() {
powerTable = PowerTable.Table(document.querySelector('.results-view'), config)
}