Vue Smart Table (DataTable) Component API

Smart Table (DataTable) API

Explore the API reference for the Vue Smart Table (DataTable) component and discover how to effectively utilize its props for customization.

On this page

CSmartTable

jsx
import { CSmartTable } from '@coreui/vue-pro'

Props

PropertyDefaultType
activePage1number

Sets active page. If 'pagination' prop is enabled, activePage is set only initially.

cleaner-boolean

When set, displays table cleaner above table, next to the table filter (or in place of table filter if tableFilter prop is not set) Cleaner resets tableFilterValue, columnFilterValue, sorterValue. If clean is possible it is clickable (tabIndex="0" role="button", color="danger"), otherwise it is not clickable and transparent. Cleaner can be customized through the cleanerIcon slot.

clickableRows-boolean

Style table items as clickable.

columnFilter-boolean, ColumnFilter

When set, displays additional filter row between table header and items, allowing filtering by specific column. Column filter can be customized, by passing prop as object with additional options as keys. Available options: - external (Boolean) - Disables automatic filtering inside component. - lazy (Boolean) - Set to true to trigger filter updates only on change event.

columnFilterValue-ColumnFilterValue

Value of table filter. To set pass object where keys are column names and values are filter strings e.g.: { user: 'John', age: 12 }

columns-(Column | string)[]

Prop for table columns configuration. If prop is not defined, table will display columns based on the first item keys, omitting keys that begins with underscore (e.g. '_props') In columns prop each array item represents one column. Item might be specified in two ways: String: each item define column name equal to item value. Object: item is object with following keys available as column configuration: - key (required)(String) - define column name equal to item key. - filter (Boolean) - removes filter from column when set to false. - label (String) - define visible label of column. If not defined, label will be generated automatically based on column name, by converting kebab-case and snake_case to individual words and capitalization of each word. - sorter (Boolean) - disables sorting of the column when set to false - [_props](https://coreui.io/vue/docs/components/table.html#ctableheadercell) (String/Array/Object) - add props to CTableHeaderCell. - _style (String/Array/Object) - adds styles to the column header (useful for defining widths)

columnSorter-boolean, Sorter

Enables table sorting by column value. Sorting will be performed corectly only if values in column are of one type: string (case insensitive) or number. Sorter can be customized, by passing prop as object with additional options as keys. Available options: - external (Boolean) - Disables automatic sorting inside the component, allowing for external sorting control. - multiple (Boolean) - Enables sorting by multiple columns simultaneously. The sorting order will be maintained across multiple columns based on the order of interaction. - resetable (Boolean) - If set to true, clicking on the sorter cycles through three states: ascending, descending, and null (no sorting). The third click on the sorter will reset the sorting and restore the table to its original order.

If true Displays table footer, which mirrors table header. (without column filter). Or Array of objects or strings, where each element represents one cell in the table footer. Example items: ['FooterCell', 'FooterCell', 'FooterCell'] or [{ label: 'FooterCell', _props: { color: 'success' }, ...]

headertrueboolean

Set to false to remove table header.

items() => []Item[]

Array of objects, where each object represents one item - row in table. Additionally, you can customize each row by passing them by [_props](http://coreui.io/vue/docs/components/table.html#ctablerow) key and single cell by [_cellProps](http://coreui.io/vue/docs/components/table.html#ctabledatacell). Examples: - _props: { color: 'primary', align: 'middle'} - _cellProps: { all: { class: 'fw-semibold'}, 'name': { color: 'info' }}

itemsNumber4.8.0+-number

The total number of items. Use if you pass a portion of data from an external source to let know component what is the total number of items.

itemsPerPage10number

Number of items per site, when pagination is enabled.

itemsPerPageLabel'Items per page:'string

Label for items per page selector.

itemsPerPageOptions() => [5, 10, 20, 50]number[]

Items per page selector options.

itemsPerPageSelect-boolean, ItemsPerPageSelect

Adds select element over table, which is used for control items per page in pagination. If you want to customize this element, pass object with optional values: - external (Boolean) - disables automatic 'itemsPerPage' change (use to change pages externaly by 'pagination-change' event).

loading-boolean

When set, table will have loading style: loading spinner and reduced opacity. When 'small' prop is enabled spinner will be also smaller.

noItemsLabel'No items found'string

ReactNode or string for passing custom noItemsLabel texts.

pagination-boolean, Pagination

Enables default pagination. Set to true for default setup or pass an object with additional CPagination props. Default pagination will always have the computed number of pages that cannot be changed. The number of pages is generated based on the number of passed items and 'itemsPerPage' prop. If this restriction is an obstacle, you can make external CPagination instead.

paginationProps-object

Properties to [CSmartPagination](https://coreui.io/vue/docs/components/smart-pagination#csmartpagination) component.

selectable-boolean

Add checkboxes to make table rows selectable.

selectAll4.8.0+trueboolean, { external?: boolean }

Enables select all checkbox displayed in the header of the table. Can be customized, by passing prop as object with additional options as keys. Available options: - external (Boolean) - Disables automatic selection inside the component.

selected4.8.0+() => []Item[]

Array of selected objects, where each object represents one item - row in table. Example item: { name: 'John' , age: 12 }

sorterValue-SorterValue[], SorterValue

State of the sorter. Name key is column name, direction can be 'asc' or 'desc'. eg.: { column: 'status', state: 'asc' }

tableBodyProps-object

Properties to [CTableBody](https://coreui.io/vue/docs/components/table/#ctablebody) component.

tableFootProps-object

Properties to [CTableFoot](https://coreui.io/vue/docs/components/table/#ctablefoot) component.

tableFilter-boolean, TableFilter

When set, displays table filter above table, allowing filtering by specific column. Column filter can be customized, by passing prop as object with additional options as keys. Available options: - external (Boolean) - Disables automatic filtering inside component. - lazy (Boolean) - Set to true to trigger filter updates only on change event.

tableFilterLabel'Filter:'string

The element represents a caption for a component.

tableFilterPlaceholder'type string...'string

Specifies a short hint that is visible in the search input.

tableFilterValue-string

Value of table filter.

tableHeadProps-object

Properties to [CTableHead](https://coreui.io/vue/docs/components/table/#ctablehead) component.

tableProps-object

Properties to [CTable](https://coreui.io/vue/docs/components/table/#ctable) component.

Events

Event name
activePageChange

Page change callback.

  • pagenumber — active page number
columnFilterChange

Column filter change callback.

  • ColumnFilterValueobject — {[key: string]: string | number}
filteredItemsChange

Filtered items change callback.

  • itemsarray
itemsPerPageChange

Pagination change callback.

  • itemsPerPageNumbernumber — items per page number
rowChecked

Row checked callback.

  • itemobject
  • valueboolean — true if row is checked, false otherwise
rowClick

Row click callback.

  • itemobject
  • indexnumber
  • columnNamestring
  • eventevent
selectAll

Select all callback.

selectedItemsChange

Selected items change callback.

  • itemsarray
sorterChange

Sorter value change callback.

  • SorterValueobject — | SorterValue[] { column?: string, state?: number | string}
  • SorterValuearray — []
tableFilterChange

Table filter change callback.

  • tableFilterValuestring