Web Component: j-DataTable
j-DataTable
BETA: This component is targeted for SPA and server-side listing.
- jComponent
v19|v20 - please try to understand the functionality
- supports pagination
- needed
bootstrapgrid system - supports sorting
- supports vertical/horizontal scrolling
- responsive
- supports dark mode
Data-source needs to contain:
{
cols: [{ name: 'id', ... }], // optional, can be defined inline in HTML
items: [{ name: 'Row 1' }, { name: 'Row 2' }, ...] // items
page: 1, // current pages
pages: 30, // count of pages
limit: 5, // items limit per page
count: 150 // count of items in DB
}
Configuration:
pluralizepages{String}pluralization for pages (optional, default:# pages,# page,# pages,# pages)pluralizeitems{String}pluralization for items (optional, default:# items,# item,# items,# items)height{Number/String}height of grid, supported values:auto(default), NEWfluid,parentorNUMBERas height orselectorfor jQuery.closest()- NEW
minheight{Number}minimal height of grid, works withfluidandautoheight (default:300) - NEW
parent{String}selector forautoheight option (default:window) margin{Number}a top margin for height (optional, default:0)click{String}a link tofunction(row, grid, row_el), it's executed if the user clicks on a rowhighlight{Boolean}each selected row (afterclick) will be highlighted (default:false)unhighlight{Boolean}enablesundo highlightingof selected row (default:true)checked{String}pathto a variable or path tofunction(rows, grid)is executed if the user selected/checked some rowsautoselect{Boolean}enables auto-select of first row in grid, it performsEXEC(config.click), default:falseexec{String}a link tofunction(type, page, sort)for server-side operations only (it disables client-side sorting & filtering), supported types:refreshorpagechanged{String}pathto a variable or path tofunction(rows, grid)is executed if the user changed some rowsdblclick{String}a link tofunction(row, grid, row_el)method, it's executed if the user double-clicks on a rownoborder{Boolean}can disable a border around the grid (default:false)colwidth{Number}a default width for columns (default:150)editable{String}a link tofunction(opt)when the user performs editingcontextmenu{String}a link tofunction(e, grid)when the user raises context menu
Column properties:
name{String}a name of field in the row objecttext{String}a column label, text with.fa fa-homewill render FontAwesome iconwidth{Number}a column width (optional, defaultconfig.colwidth)align{String}can becenterorright(optional, default:left)template{String}can be a Tangular template and the model is the entire object of rowsort{Boolean}enables sorting (optional, default:false)format{String/Number}can be used for date and numbers (count of decimals) field (optional), e.g.dd.MM.yyyycurrency{String}a currency formatter, just add a currencyclass{String}optional, a custom column class nameempty{String/Boolean}optional, can rewrite empty value with the value defined in empty field (truevalue uses---as a default value)type{String}optional, can contain a data-type (boolean,dateornumber) for the fieldeditable{Boolean}enables editing
Methods:
component.redrawrow(row_object/index)redraws row or NEW: replaces+redrawsrow_objectwith a newnew_object_rowcomponent.clear()clears all changescomponent.select(row)selectsrowmust be the same object as in data-sourcecomponent.rebind(columnsdeclaration)the method rebinds the schema- NEW:
component.reload()executesconfig.execwith the current filter and sorting - NEW:
component.empty()empties all rows
Good to know:
SET('link.to.data', data, 'noscroll')-->noscrolltype disables reseting of scrolling
How to extend a class of row?
- look to the
{{ if activeline, it extends a class of row by addingdg-active-classif theactivewill be valid
[
'{{ if active }} dg-active-class{{ fi }}',
{ name: 'name', text: 'Name', width: 200 },
// other columns ...
]
Author
- Peter Širka petersirka@gmail.com
- License
Created
10. may 2020
Updated
20. july 2023
jComponent library
19 | 20
Version
v1
License
https://www.totaljs.com/license/
Dark mode
Yes
Responsive
Yes
Author
Peter Širka
Email
petersirka@gmail.com

