Introduction
Version : Beta v0.2.1
Features
- New Buttons 'reload', 'cardview'
- Three states sort Ascending > Descending > Original
- Built-In Functions Show Row Number, Show Checkbox
- Useful Methods getSelectedRowIds(), getSelectedRowDatas(), and etc
Dependencies
-
DataTables - With following extensions included ( Warmly Reminder : It is encouraged to include all extensions in the sake of missing any functionalities. )
- Buttons
- Column Visibilty
- HTML5 Export
- HTML5 JSZip
- pdfmake
- Print View
- DateTime
- Scroller
- SearchBuilder
- SearchPanes
- Select
- order.neutral() - DataTables Plug-ins
- datetime - DataTables Plug-ins
- jQuery - Version 3.+
- Lodash
- Moment.js
Recommended Plugins
Get Started
Include EnhanceDataTable library after DataTables library.
<link rel="stylesheet" href="path-to-DataTables/datatables.min.css" type="text/css" />
<script type="text/javascript" src="path-to-DataTables/datatables.min.js"></script>
<!-- ## Remember to include all DataTables related libraries and other necessary dependency libraries ## -->
<link rel="stylesheet" href="path-to-EnhanceDataTable/EnhanceDataTable.css" type="text/css" />
<script type="text/javascript" src="path-to-EnhanceDataTable/EnhanceDataTable.js">
Sample
Default Layout - Bootstrap 5
Column1 | Column2 | Column3 | Column4 | Column5 |
---|
Custom Layout - Bootstrap 5
Column1 | Colspan1 | Colspan2 | ||
---|---|---|---|---|
Custom Date Format | Column3 | Column4 | Column5 |
Simple Layout - Bootstrap 5
Column1 | Custom Date Format | Column3 | Column4 | Column5 |
---|
Simple Layout - Draw Data (Using Template Snippet)
Column1 | Custom Date Format | Column3 | Column4 | Column5 |
---|
Sticky Header
Column1 | Column2 | Column3 | Column4 | Column5 |
---|
Issue:
- Cardview sometimes render Date-Format failed due to data changed with .cardview-col-header included, 24 Mar 2023
Milestone:
- -
Property
Description
Columns which will be hide when turns into card view, and show again then turns into table view. Those hidden columns still able to show out by toggle the column visibilty.
Types
Array
Default
[ ]
Example
Description
Three states sorting. [ Ascending > Descending > Original ]
Types
Boolean
Default
true
Example
Description
Show built-in row number column.
Types
Boolean
Default
true
Example
Description
Show built-in row reorder column.
Types
Boolean
Default
false
Example
Description
Show built-in checkbox column.
Types
Boolean
Default
false
Example
Description
'Check/Un-Check All' only apply to visible checkboxes.
Types
Boolean
Default
false
Example
Description
Enable built-in checkbox event listener on custom checkbox.
Types
Boolean
Default
false
Example
Description
Make the thead become 'position: sticky;' with default 'top: 0px;'.
Types
Boolean
Default
false
Example
Description
Checkbox header class.
Types
String
Default
'.column-checkbox-header'
Example
Description
Checkbox class.
Types
String
Default
'.column-checkbox'
Example
Description
Row Reorder header class.
Types
String
Default
'.column-rowReorder-header'
Example
Description
Row Reorder class.
Types
String
Default
'.column-rowReorder'
Example
Method
Description
Get Ajax URL of DataTables.
Example
Description
Set Ajax URL of DataTables.
Parameter
Name | Type | Optional | Description | |
---|---|---|---|---|
1 | url | string |
Yes | New Ajax URL. |
Example
Description
Get current view DataTables.
Example
Description
Set DataTables view.
Parameter
Name | Type | Default | Optional | Description | |
---|---|---|---|---|---|
1 | view | string |
'table' | Yes | View to set. |
Example
Description
Toggle between 'table' and 'card' view.
Example
Description
Get all rows.
Returns
Array of all rows loaded in the DataTable. 'all' to get all rows; 'filtered' to get only filtered rows.
Example
Description
Get data of a row.
Parameter
Name | Type | Description | |
---|---|---|---|
1 | view | string|number |
Row index. |
Returns
Data object specified by row index.
Example
Description
Get ID of selected rows.
Parameter
Name | Type | Default | Optional | Description | |
---|---|---|---|---|---|
1 | rowSelector | string |
'.selected' | Yes | Row selector. |
Returns
Array of selected rows ID.
Example
Description
Get data of selected rows.
Parameter
Name | Type | Default | Optional | Description | |
---|---|---|---|---|---|
1 | rowSelector | string |
'.selected' | Yes | Row selector. |
Returns
Array of selected rows data.
Example
Description
Reload DataTable data.
Parameter
Name | Type | Default | Optional | Description | |
---|---|---|---|---|---|
1 | callback | function |
null | Yes | Function which is executed when the data has been reloaded and the table fully redrawn. |
2 | resetPaging | boolean |
true | Yes | Reset or hold the current paging position. |
Example
Description
Register DataTable events listener. Refer to on().
Example
Description
Filter data.
Parameter
Name | Type | Default | Optional | Description | |
---|---|---|---|---|---|
1 | input | string |
'' | Yes | Search string to apply to the DataTables. |
Example
Description
Update data.
Parameter
Name | Type | Default | Optional | Description | |
---|---|---|---|---|---|
1 | data | Array of object |
New data. | ||
2 | resetPaging | boolean |
true | Yes | Reset or hold the current paging position. |
Example
Description
Clear data.
Example
Description
Restore the order in which data was read into a DataTable.
Example
Description
Select a row.
Parameter
Name | Type | Description | |
---|---|---|---|
1 | view | string|number |
Row index. |
Example
Description
Deselect a row.
Parameter
Name | Type | Description | |
---|---|---|---|
1 | view | string|number |
Row index. |
Example
Event
Description
Toggle view event - fired when DataTables view changes.
Type
Parameter | Description | |
---|---|---|
1 | e | Custom event object. |