Datatables
Angular Bootstrap 5 Datatables
The Datatable is a component which mix tables with advanced options like searching, sorting and pagination.
Note: Read the API tab to find all available options and advanced customization
Video tutorial
Basic example
Name | Position | Office | Age | Start date | Salary |
---|---|---|---|---|---|
Tiger Nixon | System Architect | Edinburgh | 61 | 2011/04/25 | $320,800 |
Sonya Frost | Software Engineer | Edinburgh | 23 | 2008/12/13 | $103,600 |
Jena Gaines | Office Manager | London | 30 | 2008/12/19 | $90,560 |
Quinn Flynn | Support Lead | Edinburgh | 22 | 2013/03/03 | $342,000 |
Charde Marshall | Regional Director | San Francisco | 36 | 2008/10/16 | $470,600 |
Haley Kennedy | Senior Marketing Designert | London | 43 | 2012/12/18 | $313,500 |
Tatyana Fitzpatrick | Regional Director | London | 19 | 2010/03/17 | $385,750 |
Michael Silva | Marketing Designer | London | 66 | 2012/11/27 | $198,500 |
Paul Byrd | Chief Financial Officer (CFO) | New York | 64 | 2010/06/09 | $725,000 |
Gloria Little | Systems Administrator | New York | 59 | 2009/04/10 | $237,500 |
Rows per page:
Search
The search field is not a part of the Datatable - place an input field on your page and use
.search()
method to filter entries.
Name | Position | Office | Age | Start date | Salary |
---|---|---|---|---|---|
Tiger Nixon | System Architect | Edinburgh | 61 | 2011/04/25 | $320,800 |
Garrett Winters | Accountant | Tokyo | 63 | 2011/07/25 | $170,750 |
Ashton Cox | Junior Technical Author | San Francisco | 66 | 2009/01/12 | $86,000 |
Cedric Kelly | Senior Javascript Developer | Edinburgh | 22 | 2012/03/29 | $433,060 |
Airi Satou | Accountant | Tokyo | 33 | 2008/11/28 | $162,700 |
Brielle Williamson | Integration Specialist | New York | 61 | 2012/12/02 | $372,000 |
Herrod Chandler | Sales Assistant | San Francisco | 59 | 2012/08/06 | $137,500 |
Rhona Davidson | Integration Specialist | Tokyo | 55 | 2010/10/14 | $327,900 |
Colleen Hurst | Javascript Developer | San Francisco | 39 | 2009/09/15 | $205,500 |
Sonya Frost | Software Engineer | Edinburgh | 23 | 2008/12/13 | $103,600 |
Rows per page:
Advanced search
When using the searching method, you can specify which columns it should take under consideration - pass as a second argument a field (or array of fields). By default, searching will apply to all columns.
Name | Position | Office | Age | Start date | Salary |
---|---|---|---|---|---|
Tiger Nixon | System Architect | Edinburgh | 61 | 2011/04/25 | $320,800 |
Garrett Winters | Accountant | Tokyo | 63 | 2011/07/25 | $170,750 |
Ashton Cox | Junior Technical Author | San Francisco | 66 | 2009/01/12 | $86,000 |
Cedric Kelly | Senior Javascript Developer | Edinburgh | 22 | 2012/03/29 | $433,060 |
Airi Satou | Accountant | Tokyo | 33 | 2008/11/28 | $162,700 |
Brielle Williamson | Integration Specialist | New York | 61 | 2012/12/02 | $372,000 |
Herrod Chandler | Sales Assistant | San Francisco | 59 | 2012/08/06 | $137,500 |
Rhona Davidson | Integration Specialist | Tokyo | 55 | 2010/10/14 | $327,900 |
Colleen Hurst | Javascript Developer | San Francisco | 39 | 2009/09/15 | $205,500 |
Sonya Frost | Software Engineer | Edinburgh | 23 | 2008/12/13 | $103,600 |
Rows per page:
Selectable rows
You can easily build datatable with selectable rows.
|
Name | Position | Office | Age | Start date | Salary |
---|---|---|---|---|---|---|
|
Tiger Nixon | System Architect | Edinburgh | 61 | 2011/04/25 | $320,800 |
|
Garrett Winters | Accountant | Tokyo | 63 | 2011/07/25 | $170,750 |
|
Ashton Cox | Junior Technical Author | San Francisco | 66 | 2009/01/12 | $86,000 |
|
Cedric Kelly | Senior Javascript Developer | Edinburgh | 22 | 2012/03/29 | $433,060 |
|
Airi Satou | Accountant | Tokyo | 33 | 2008/11/28 | $162,700 |
|
Brielle Williamson | Integration Specialist | New York | 61 | 2012/12/02 | $372,000 |
|
Herrod Chandler | Sales Assistant | San Francisco | 59 | 2012/08/06 | $137,500 |
|
Rhona Davidson | Integration Specialist | Tokyo | 55 | 2010/10/14 | $327,900 |
|
Colleen Hurst | Javascript Developer | San Francisco | 39 | 2009/09/15 | $205,500 |
|
Sonya Frost | Software Engineer | Edinburgh | 23 | 2008/12/13 | $103,600 |
Rows per page:
Scroll
Setting maximum height/width will enable vertical/horizontal scrolling.
Name | Position | Office | Age | Start date | Salary |
---|---|---|---|---|---|
Tiger Nixon | System Architect | Edinburgh | 61 | 2011/04/25 | $320,800 |
Garrett Winters | Accountant | Tokyo | 63 | 2011/07/25 | $170,750 |
Ashton Cox | Junior Technical Author | San Francisco | 66 | 2009/01/12 | $86,000 |
Cedric Kelly | Senior Javascript Developer | Edinburgh | 22 | 2012/03/29 | $433,060 |
Airi Satou | Accountant | Tokyo | 33 | 2008/11/28 | $162,700 |
Brielle Williamson | Integration Specialist | New York | 61 | 2012/12/02 | $372,000 |
Herrod Chandler | Sales Assistant | San Francisco | 59 | 2012/08/06 | $137,500 |
Rhona Davidson | Integration Specialist | Tokyo | 55 | 2010/10/14 | $327,900 |
Colleen Hurst | Javascript Developer | San Francisco | 39 | 2009/09/15 | $205,500 |
Sonya Frost | Software Engineer | Edinburgh | 23 | 2008/12/13 | $103,600 |
Rows per page:
Fixed header
Use the fixedHeader
option to ensure that a table's header is always visible
while scrolling.
Name | Position | Office | Age | Start date | Salary |
---|---|---|---|---|---|
Tiger Nixon | System Architect | Edinburgh | 61 | 2011/04/25 | $320,800 |
Garrett Winters | Accountant | Tokyo | 63 | 2011/07/25 | $170,750 |
Ashton Cox | Junior Technical Author | San Francisco | 66 | 2009/01/12 | $86,000 |
Cedric Kelly | Senior Javascript Developer | Edinburgh | 22 | 2012/03/29 | $433,060 |
Airi Satou | Accountant | Tokyo | 33 | 2008/11/28 | $162,700 |
Brielle Williamson | Integration Specialist | New York | 61 | 2012/12/02 | $372,000 |
Herrod Chandler | Sales Assistant | San Francisco | 59 | 2012/08/06 | $137,500 |
Rhona Davidson | Integration Specialist | Tokyo | 55 | 2010/10/14 | $327,900 |
Colleen Hurst | Javascript Developer | San Francisco | 39 | 2009/09/15 | $205,500 |
Sonya Frost | Software Engineer | Edinburgh | 23 | 2008/12/13 | $103,600 |
Rows per page:
Async data
Loading content asynchronously is an important part of working with data tables - with MDB Datatable you can easily display content after fetching it from API.
Name | Phone | Username | Website | Address | Company |
---|
Loading results...
Rows per page:
Action buttons
With the Datatable it's possible to render custom content, such as action buttons and attach listeners to their events.
Name | Position | Office | Contact |
---|---|---|---|
Tiger Nixon | System Architect | Edinburgh | |
Sonya Frost | Software Engineer | Edinburgh | |
Tatyana Fitzpatrick | Regional Director | London |
Rows per page:
Cell formatting
Use [ngStyle]
attribute directive to implement cell formatting to color individual cells.
Product | Quantity | Purchases |
---|---|---|
Product 5 | 104 | 240 |
Product 4 | 89 | 230 |
Product 9 | 4 | 206 |
Product 8 | 50 | 199 |
Product 6 | 97 | 187 |
Product 7 | 167 | 130 |
Product 2 | 45 | 110 |
Product 1 | 10 | 103 |
Product 11 | 22 | 100 |
Product 10 | 120 | 88 |
Rows per page:
Clickable rows
Click on the row to preview the message.
Selecting the row with checkbox doesn't trigger rowClick
event.
Note: To prevent this action with other clickable elements within the row, call
stopPropagation()
method.
Note: This feature cannot be used simultaneously with edit
option.
Rows per page:
Datatables - API
Import
Inputs
MdbTableDirective
Name | Type | Default | Description |
---|---|---|---|
bordered
|
Boolean | false |
Adds borders to a datatable |
borderless
|
Boolean | false |
Removes all borders from a datatable |
dataSource
|
T[] | [] |
Changes table data source array |
fixedHeader
|
Boolean | false |
When it's set to true, the table's header will remain visible while scrolling |
filterFn |
(data: T, searchTerm: string) => boolean | - |
Changes function used for data search |
hover |
Boolean | false |
Changes the background color of a hovered row |
pagination
|
MdbTablePaginationComponent | - |
Changes attached table pagination component |
sort
|
MdbTableSortDirective | - |
Changes attached table sort directive |
sm |
Boolean | false |
Decreases a row's paddings |
striped
|
Boolean | false |
Slightly changes the background's color in every other row |
MdbTableSortHeaderDirective
Name | Type | Default | Description |
---|---|---|---|
disableSort
|
boolean | false |
Disables sorting for chosen column |
forceSort
|
boolean | false |
When it's set to true, the table's sort will toggle between two options: ascending and descending. The initial state will not be one of the options. |
mdbTableSortHeader
|
string | '' |
Changes name of the sort header |
MdbTablePaginationComponent
Name | Type | Default | Description |
---|---|---|---|
allText
|
string | 'All' |
Defines text for 'All' option |
disabled
|
boolean | false |
Whether pagination should be disabled |
entries
|
number | 10 |
Changes number of displayed entries |
entriesOptions
|
Array | [10, 25, 50, 200] |
Options available to choose from in a pagination select (rows per page) |
nextButtonDisabled
|
boolean | false |
Whether next button should be disabled |
page
|
number | 0 |
Sets current page |
prevButtonDisabled
|
boolean | false |
Whether previous button should be disabled |
rowsPerPageText
|
string | Rows per page |
Changes 'Rows per page' text value |
ofText
|
string | of |
Changes 'of' text value |
showAllEntries
|
boolean | false |
Defines whether 'All' option is available |
total
|
number | 0 |
Changes number of total pagination entries |
Outputs
MdbTableSortDirective
Name | Type | Description |
---|---|---|
sortChange
|
EventEmitter<MdbSortChange> | Event fired on data sort change |
MdbTablePaginationComponent
Name | Type | Description |
---|---|---|
paginationChange
|
EventEmitter<MdbPaginationChange> | Event fired on pagination change |