DataBox is an information show library for jQuery and Bootstrap that generates searchable tables, card grids, lists, tree views, and Kanban boards from any information.
Options
- 4 built-in views: information desk, card grid, record, and Kanban board.
- Swap between enabled views by means of UI buttons or JavaScript.
- International search, per-column filters, fast filters, and an AND/OR question builder.
- Pagination, steady scrolling modes, multi-column sorting, and AJAX server-side processing.
- Inline table-cell enhancing with textual content, quantity, date, choose, and checkbox inputs.
- Single or a number of row choice and configurable bulk actions.
- CSV and Excel-compatible
.xlsexports, clipboard copying, and browser printing or PDF saving. - Expandable row particulars, grouping, footer calculations, mounted columns, and column reordering.
- Drag-and-drop Kanban playing cards with an software callback for modifications.
- Saved search, sorting, pagination, and think about state, plus English and Portuguese textual content dictionaries.
How To Use It
Set up
Load Bootstrap CSS, jQuery, the Bootstrap JavaScript bundle, and DataBox jQuery plugin within the doc. Font Superior 6 is elective for default icons.
<hyperlink rel="stylesheet" href="https://cdn.jsdelivr.web/npm/[email protected]/dist/css/bootstrap.min.css"> <hyperlink rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css"> <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> <script src="https://cdn.jsdelivr.web/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> <script src="./dataBox.min.js"></script>
Fundamental Utilization
Give DataBox.init() a container ID, a report array, and the columns to show.Â
<div id="staff-directory"></div>
<script>
const workers = [
{ id: 1, name: 'Avery Morgan', team: 'Engineering', role: 'Developer' },
{ id: 2, name: 'Jordan Lee', team: 'Design', role: 'Designer' },
{ id: 3, name: 'Taylor Reed', team: 'Operations', role: 'Coordinator' }
];
const listing = DataBox.init({
goal: '#staff-directory',
information: workers,
language: 'en-US',
views: {
desk: {
lively: true,
title: 'Desk',
columns: [
{ data: 'name', title: 'Name' },
{ data: 'team', title: 'Team' },
{ data: 'role', title: 'Role' }
]
},
card: { lively: true, title: 'Playing cards' }
},
search: { lively: true, fields: ['name', 'team', 'role'] },
pagination: { restrict: 10 }
});
listing.setView('desk');
</script>
Swap Between Views and Allow Kanban
Kanban teams data by a subject comparable to standing. Place <div id="project-board"></div> on the web page. When a card strikes, onKanbanDrop receives the report and the earlier and new group values.
const board = DataBox.init({
goal: '#project-board',
information: [
{ id: 101, name: 'Landing page', status: 'Todo' },
{ id: 102, name: 'QA review', status: 'In progress' },
{ id: 103, name: 'Release notes', status: 'Done' }
],
language: 'en-US',
views: {
card: { lively: true },
desk: {
lively: true,
columns: [
{ data: 'name', title: 'Task' },
{ data: 'status', title: 'Status' }
]
},
kanban: {
lively: true,
groupBy: 'standing',
allowDragDrop: true
}
},
callbacks: {
onKanbanDrop: operate(merchandise, oldGroup, newGroup) {
console.log(merchandise.title, oldGroup, newGroup);
// Save the modified standing to your backend if wanted.
}
}
});
board.setView('kanban');
The cardboard transfer updates the native report. Ship that change to your API from onKanbanDrop when the board makes use of saved backend information.
Load Knowledge From an API
Put <div id="orders"></div> within the web page and configure ajax.url. Server-side mode sends pagination, sorting, and search parameters to the endpoint. The server should apply them and return the matching data and counts.
const orders = DataBox.init({
goal: '#orders',
language: 'en-US',
views: {
card: { lively: false },
desk: {
lively: true,
columns: [
{ data: 'id', title: 'Order ID' },
{ data: 'customer', title: 'Customer' },
{ data: 'total', title: 'Total' }
]
}
},
ajax: {
url: '/api/orders',
methodology: 'GET',
serverSide: true
},
pagination: { restrict: 20 }
});
Implement /api/orders in your software to just accept these parameters. Return an object with the DataBox response fields:
{
"information": [{ "id": 101, "customer": "Avery", "total": 125 }],
"recordsTotal": 240,
"recordsFiltered": 240
}
Edit Cells and Deal with Adjustments
Place <div id="editable-orders"></div> in your web page. Set inlineEdit: true, mark the editable columns, and deal with onEdit. The callback receives the outdated and new values earlier than DataBox writes the edited subject to the report.
const editableTable = DataBox.init({
goal: '#editable-orders',
information: [
{ id: 1, item: 'Keyboard', status: 'Pending' },
{ id: 2, item: 'Monitor', status: 'Shipped' }
],
language: 'en-US',
views: {
card: { lively: false },
desk: {
lively: true,
inlineEdit: true,
columns: [
{ data: 'item', title: 'Item' },
{
data: 'status',
title: 'Status',
editable: true,
editType: 'select',
editOptions: [
{ value: 'Pending', label: 'Pending' },
{ value: 'Shipped', label: 'Shipped' }
]
}
]
}
},
callbacks: {
onEdit: operate(newValue, oldValue, merchandise, column) {
console.log(merchandise.id, column.information, oldValue, newValue);
}
}
});
All Configuration Choices
Views and Column Definitions
| Possibility | Objective and default |
|---|---|
goal |
Required selector for the container, for instance '#grid'. |
information |
Array of data for client-side rendering. |
views.desk.lively |
Allow desk view. Default false. |
views.desk.columns |
Desk column definitions. Required for a usable desk view. |
views.desk.cssClass |
Desk CSS courses. Default 'desk table-striped table-hover'. |
views.desk.title |
Non-obligatory view-switcher caption, for instance 'Desk'. |
views.desk.responsive |
Wrap the desk for horizontal scrolling. Default true. |
views.desk.sortable |
Allow header sorting. Default true. |
views.desk.particulars |
Operate to render expandable row particulars. Default null. |
views.desk.columnVisibility |
Present or conceal desk columns by means of a menu. Default false. |
views.desk.columnReorder |
Allow column drag-and-drop reordering. Default false. |
views.desk.fixedColumns |
Sticky columns, specified as { left: 0, proper: 0 }. |
views.desk.footer |
Allow desk footer calculations. Default false. |
views.desk.inlineEdit |
Allow enhancing for columns marked editable. Default false. |
views.card.lively |
Allow card view. Default true. |
views.card.template |
Operate returning card HTML. Default null. |
views.card.columns |
Variety of playing cards per grid row. Default 3. |
views.card.itemCssClass |
CSS courses on every card grid merchandise. Default 'col-md-4 mb-3'. |
views.card.cssClass |
Card grid wrapper courses. Default row. |
views.card.particulars |
Non-obligatory operate returning expandable card particulars. |
views.record.lively |
Allow record view. Default false. |
views.record.template |
Operate returning record merchandise HTML. Default null. |
views.record.particulars |
Operate returning expanded record particulars. Default null. |
views.record.cssClass |
Checklist wrapper courses. Default list-group. |
views.record.itemCssClass |
Checklist merchandise courses. Default list-group-item. |
views.kanban.lively |
Allow Kanban view. Default false. |
views.kanban.groupBy |
File subject for Kanban columns. Required when Kanban is enabled. |
views.kanban.allowDragDrop |
Permit transferring playing cards between teams. Default false. |
views.kanban.columnHeader |
Operate returning group header HTML. Default null. |
views.kanban.cardTemplate |
Operate returning Kanban card HTML. Default null. |
views.kanban.cssClass |
Kanban board wrapper courses. Default row. |
views.kanban.columnCssClass |
Kanban column courses. Default col-md-4. |
views.kanban.columnItemCssClass |
Kanban card-column merchandise courses. Default col-12 mb-3. |
Desk Column Properties
| Column property | Objective and default |
|---|---|
information |
Required report key. Dot notation works for nested values. |
title |
Header textual content. Defaults to the information key. |
render |
Cell renderer (worth, merchandise, sort), with show and export varieties. |
className |
Further CSS courses for the cell. |
seen |
Preliminary column visibility. Default true. |
orderable |
Permit sorting by the column. Default true. |
searchable |
Allow column search. Default true. |
editable |
Permit enhancing when desk inline enhancing is enabled. Default false. |
editType |
textual content, quantity, date, choose, or checkbox. Default textual content. |
editOptions |
{ worth, label } decisions for a choose editor. |
footer |
Footer mixture (sum, avg, rely, min, max) or formatter. Object choices embody sort, prefix, suffix, locale, and format. |
Search, Sorting, and Pagination
| Possibility | Objective and default |
|---|---|
search.lively |
Allow search. Default true. |
search.world |
Declared global-search setting. Default true; the built-in search subject is managed by search.lively on this construct. |
search.perColumn |
Present per-column search inputs. Default false. |
search.debounce |
Enter delay in milliseconds. Default 300. |
search.placeholder |
International search placeholder. Default language label. |
search.fields |
Fields searched globally. Default []; DataBox in any other case checks desk column keys. Set this explicitly for a card-only, list-only, or Kanban-only show. |
sorting.lively |
Allow sorting. Default true. |
sorting.multiColumn |
Permit Shift-click multi-column sorting. Default true. |
sorting.serverSide |
Declared sorting setting. Default false; AJAX server-side habits is managed by ajax.serverSide. |
pagination.sort |
paginated, digital, or infinite. Default paginated. |
pagination.restrict |
Information per web page or batch. Default 10. |
pagination.limits |
Web page-size decisions. Default [10,25,50,100]. |
pagination.limiter |
Present page-size selector. Default true. |
pagination.maxButtons |
Most numbered web page buttons. Default 5. |
pagination.showFirstLast |
First and final web page buttons. Default true. |
pagination.showInfo |
Present merchandise rely data. Default true. |
pagination.scrollDirection |
vertical or horizontal. Default vertical. |
pagination.scrollSize |
Scrollready container dimension. Default automated. |
AJAX and Knowledge Processing
| Possibility | Objective and default |
|---|---|
ajax.url |
URL for JSON information. Default empty string. |
ajax.methodology |
HTTP methodology. Default GET. |
ajax.dataType |
jQuery response information sort. Default json. |
ajax.headers |
Request headers. Default {}. |
ajax.params |
Further request parameters. Default {}. |
ajax.serverSide |
Delegate paging, filtering, and sorting to the server. Default false. |
ajax.beforeSend |
Request callback (xhr, params). |
ajax.success |
Non-obligatory customized success handler (response, occasion). |
ajax.error |
Non-obligatory error handler (xhr, standing, error). |
ajax.full |
Request completion callback (xhr, occasion). |
Choice, Export, and Superior Filters
| Possibility | Objective and default |
|---|---|
choice.lively |
Allow report choice. Default false. |
choice.mode |
single or multi. Default single. |
choice.checkbox |
Present choice checkboxes. Default true. |
bulkActions.lively |
Allow the selected-record motion bar. Default false. |
bulkActions.actions |
Motion definitions with label, elective icon and class, and motion(gadgets, ids, occasion). |
export.lively |
Allow export controls. Default false. |
export.buttons |
Default ['copy','csv','excel','pdf','print']. Excel writes an XML-based .xls file; PDF opens the browser print movement. |
export.filename |
Export file base title. Default databox-export. |
export.title |
Print/PDF title. Default null. |
export.orientation |
portrait or panorama. Default portrait. |
export.pageSize |
Print/PDF paper dimension. Default A4. |
queryBuilder.lively |
Allow the AND/OR question builder. Operators embody equality, accommodates, begins/ends with, numeric comparisons, empty checks, and between. Default false. |
queryBuilder.columns |
Fields out there in superior search. Default []. |
quickFilters.lively |
Allow preset filters. Default false. |
quickFilters.filters |
Array of filter definitions. Varieties: dropdown, buttons, date. |
rowGroup.lively |
Allow grouping in desk view. Default false. |
rowGroup.dataSrc |
Group-by subject. Required for grouping. |
rowGroup.startRender |
Non-obligatory group header operate. |
rowGroup.endRender |
Non-obligatory group footer operate. |
rowGroup.collapse |
Permit group collapse. Default true. |
stateSave.lively |
Allow UI-state storage. Default false. |
stateSave.period |
State lifetime in seconds. Default 7200. |
stateSave.storage |
localStorage or sessionStorage. Default localStorage. |
stateSave.saveCallback |
Customized state-saving operate. |
stateSave.loadCallback |
Customized state-loading operate. |
language |
pt-PT (default) or en-US. |
emptyState.message |
Customized empty-results message. Default locale textual content. |
emptyState.icon |
Icon class for empty outcomes. Default fas fa-search. |
API Strategies
Use DataBox.init(config) to create a grid. DataBox.getInstance(id) finds an present occasion by its container ID, and DataBox.destroy(id) removes it.Â
const occasion = DataBox.getInstance('staff-directory');
occasion.search('Engineering').setView('desk');
occasion.clearSearch();
Occasion Strategies
| Methodology | Conduct |
|---|---|
setView(view) |
Change to an enabled view. |
search(time period) |
Apply world search. |
clearSearch() |
Clear the search, superior question, and lively fast filters. |
setPage(web page) |
Change the present numbered web page. |
reload() |
Reprocess information from web page one. Server-side mode requests new information. |
type(column, route) |
Kind a subject, utilizing asc or desc. |
clearSort() |
Take away lively sorting. |
getData() |
Return data within the lively view/web page. |
getAllData() |
Return the entire client-side dataset. |
getTotalItems() |
Return the filtered report rely. |
getCurrentPage() |
Return the web page quantity. |
getTotalPages() |
Return the overall web page rely. |
getSelectedItems() |
Return chosen data from the lively web page. |
getSelectedIds() |
Return chosen report IDs. |
clearSelection() |
Clear chosen data. |
addItem(merchandise) |
Append a report to client-side information. |
removeItem(idOrFn) |
Take away data by ID or filter predicate. |
updateItem(id, updates) |
Replace a report matching its ID. |
setAjaxParams(params) |
Merge extra AJAX request parameters. |
clearState() |
Take away saved UI state. |
destroy() |
Take away the rendered UI and its handlers. |
Callbacks
Register lifecycle and interplay callbacks in callbacks.
For a client-side AJAX request, onDataLoaded can run throughout information processing and once more after the request succeeds. Keep away from non-idempotent writes on this callback.
| Callback | When it runs |
|---|---|
onInitialized |
After occasion initialization. |
onDataLoaded |
After information processing or loading. |
onViewChanged |
After switching views. |
onPageChanged |
After a web page change. |
onSearch |
When search is invoked by means of the API. |
onSort |
When desk sorting modifications. |
onRowClick |
When a report component is clicked. |
onSelectionChanged |
After report choice modifications. |
onRowExpand |
When desk particulars develop. |
onRowCollapse |
When desk particulars collapse. |
onColumnReorder |
After column reordering. |
onColumnVisibility |
After a column’s visibility modifications. |
onEdit |
When an edit is saved, earlier than its new worth is assigned to the report. |
onKanbanDrop |
After a Kanban card strikes between teams. |
onBulkAction |
After a configured bulk motion runs. |
onError |
On an AJAX failure. |
onStateSave |
Throughout default UI-state saving. |
onStateLoad |
When a customized state-load callback receives saved state. |
FAQs
Does DataBox work in a challenge that doesn’t use jQuery?
No. The core requires jQuery 3.6+ and Bootstrap 5.3+. A vanilla JavaScript software would wish to load these dependencies or select a distinct information grid.
Why is my desk empty when the cardboard view works?
A desk wants views.desk.columns with information keys matching your data. Playing cards are lively by default, so disable views.card.lively while you need a table-only view.
Can DataBox course of filters and pagination on the server?
Sure. Set ajax.serverSide to true and implement an endpoint that accepts DataBox’s pagination, sorting, and search parameters. Return information, recordsTotal, and recordsFiltered within the JSON response.
Does the PDF export create a downloadable PDF file?
The PDF motion opens a printable doc and invokes the browser print dialog. Select a PDF vacation spot within the browser to save lots of a file. The Excel motion creates an XML-based .xls export, not .xlsx.
Can I take advantage of the Tree view with the 4 built-in views?
Sure. Load the /dist/plugins/dataBox.tree.js after dataBox.min.js and register DataBox.Tree.createRenderer() because the tree view renderer. This plugin isn’t included within the four-view core.
This superior jQuery plugin is developed by SyntaxSerenity-dev. For extra Superior Usages, please examine the demo web page or go to the official web site.

