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
bootstrap
grid 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
,parent
orNUMBER
as height orselector
for jQuery.closest()- NEW
minheight
{Number}
minimal height of grid, works withfluid
andauto
height (default:300
) - NEW
parent
{String}
selector forauto
height 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 highlighting
of selected row (default:true
)checked
{String}
path
to 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:false
exec
{String}
a link tofunction(type, page, sort)
for server-side operations only (it disables client-side sorting & filtering), supported types:refresh
orpage
changed
{String}
path
to 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-home
will render FontAwesome iconwidth
{Number}
a column width (optional, defaultconfig.colwidth
)align
{String}
can becenter
orright
(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.yyyy
currency
{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 (true
value uses---
as a default value)type
{String}
optional, can contain a data-type (boolean
,date
ornumber
) for the fieldeditable
{Boolean}
enables editing
Methods:
component.redrawrow(row_object/index)
redraws row or NEW: replaces+redrawsrow_object
with a newnew_object_row
component.clear()
clears all changescomponent.select(row)
selectsrow
must be the same object as in data-sourcecomponent.rebind(columnsdeclaration)
the method rebinds the schema- NEW:
component.reload()
executesconfig.exec
with the current filter and sorting - NEW:
component.empty()
empties all rows
Good to know:
SET('link.to.data', data, 'noscroll')
-->noscroll
type disables reseting of scrolling
How to extend a class of row?
- look to the
{{ if active
line, it extends a class of row by addingdg-active-class
if theactive
will 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