Skip to content

Latest commit

History

82 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

bs-table

bs-table is a lightweight and user-friendly table plugin for Bootstrap, designed to efficiently manage tables with a streamlined configuration and extensive customization options.


Table Options Reference

Below is the complete list of options available for bs-table with detailed explanations for each.


General Table Options

OptionTypeDefaultDescription
classes`stringobject`'table'
toolbar`string$`null
paginationbooleanfalseEnables/disables pagination controls.
sidePaginationstring'client'Determines if pagination is done on 'client' or 'server'.
paginationVAlignstring'bottom'Vertical alignment: 'top', 'bottom', or 'both'.
paginationHAlignstring'end'Horizontal alignment: 'start' or 'end'.
pageNumbernumber1Initial page number when table loads.
pageSizenumber10Number of rows per page.
pageListarray<number>[5, 10, 25, 50, 100, 200, 'All']Dropdown options for the number of rows per page.
searchbooleanfalseAdds a search bar for filtering rows.
url`stringfunction`null
dataarraynullStatic array of data objects. Overrides url if defined.
debugbooleanfalseEnables debugging mode, which logs events and table interactions.

Sorting Options

OptionTypeDefaultDescription
sortNamestringnullSpecifies the data field to sort by on table initialization.
sortOrderstring'asc'Default sorting order. Possible values are 'asc' (ascending) or 'desc' (descending).
onSortfunctionCallback triggered when a column is sorted. Receives field and order as arguments.

Advanced Features

OptionTypeDefaultDescription
showFooterbooleanfalseDisplays a table footer.
showHeaderbooleantrueControls the visibility of the table header.
formatNoMatchesfunctionCustom HTMLMessage displayed when no matching rows are found.
showColumnsbooleanfalseDisplays a dropdown for toggling column visibility.
minimumCountColumnsnumber1Minimum number of visible columns when showColumns is enabled.
customViewbooleanfalseEnables a custom rendering view for rows.
onCustomViewfunctionCallback function for rendering rows when customView is enabled.

Column Options

Columns are defined in the columns array. Each column object accepts the following options:

OptionTypeDefaultDescription
fieldstringThe data field to map onto this column.
titlestringHeader text for the column.
sortablebooleanfalseEnables sorting for this column.
alignstring'left'Horizontal alignment of column cells. Can be 'left', 'center', or 'right'.
valignstring'top'Vertical alignment. Can be 'top', 'middle', or 'bottom'.
formatterfunctionFunction to customize the rendering of cell values.
widthstringSets the width of the column (e.g., '100px').
checkboxbooleanfalseAdds a checkbox to the column for selection purposes.
radiobooleanfalseAdds a radio button to the column for row selection.

Events

bs-table provides rich event-driven functionalities. Below is a complete list of events:

Event NameCallback ParametersDescription
onAlleventName, ...argsGlobal event that listens to all table actions.
onLoadSuccess(rows, $table)Triggered when data is successfully loaded into the table.
onLoadErrorTriggered when there is an error loading data into the table.
onPreBody(rows, $table)Triggered before the table body is rendered.
onPostBody(rows, $table)Triggered after the table body rendering is complete.
onClickCell(field, value, row, $td)Triggered when a specific cell is clicked.
onClickRow(row, $tr)Triggered when a table row is clicked.
onSort(field, order)Triggered when a column is sorted.
onRefreshTriggered when the table is refreshed through the refresh button.

Example: Event Listener

$('#example-table').on('click-row.bs.table',function(event,row,$tr){console.log('Row clicked:',row);});

How to Customize bs-table

Example Scenario: Full Feature Setup

$('#example-table').bsTable({search: true,pagination: true,pageSize: 15,showColumns: true,columns: [{field: 'id',title: 'ID',sortable: true,align: 'center'},{field: 'name',title: 'Name',formatter: value=>`<strong>${value}</strong>`},{field: 'description',title: 'Description',valign: 'middle'}],onClickRow: function(row,$tr){alert('Row clicked: '+JSON.stringify(row));}});

License

Proprietary
Contact the author for licensing inquiries.


Author

Thomas Kirsch
Email: t.kirsch@webcito.de

About

bs-table is a light and user-friendly table plugin developed for Bootstrap. Crafted with a minimalist approach, this plugin offers a straightforward, streamlined method to manage and interact with tables in a Bootstrap-based web environment.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors