Framework:
  • JavaScript / Vanilla JS
  • React.js
  • Vue.js
On this page
    CoreUI PRO for AngularThis component is part of CoreUI PRO – a powerful UI library with over 250 components and 25+ templates, designed to help you build modern, responsive apps faster. Fully compatible with Angular, Bootstrap, React.js, and Vue.js.Get CoreUI PRO

    Angular Smart Table Component (DataTable)

    Angular Smart Table provides a full set of features for displaying and manipulating tabular data. It allows you to easily create dynamic and interactive tables with features such as sorting, filtering, pagination, and searching. Angular Smart Table Component (DataTable) makes it easy to work with large datasets, and it is widely used in a variety of applications, including web-based applications, e-commerce sites, and more.

    Loading...
    ## Features - Filter items by one or all columns - Sort items by column - Integrated with CPagination component by default - Customize style of specific rows, columns and cells - Customize display of columns - Load with initial filters and sorter state - Loading state visualization - Default header labels generation based on column names ## Examples ### Basic usage
    Loading...
    Loading...
    Loading...
    Loading...
    --- ### Default header - labels generation based on column names ---
    Loading...
    Loading...
    Loading...
    --- ### Custom headers - custom table header templates
    ~4.7.7
    To add custom column header template with a *`labelTemplateName`*: 1. HTML: add `ng-template` with `cTemplateId="columnLabel_`*`labelTemplateName`*`"` and `let-column` template variable 2. TypeScript: define `IColumns[]` config with `_labelTemplateId` and optional `_data` ---
    Loading...
    Loading...
    Loading...
    --- ### Column groups The Angular Smart Table component allows grouping related columns under a shared header. This feature is useful for presenting data categorized into groups or comparing different sets. The header group spans the width of the included columns and enhances organization and readability by grouping related data. Column groups can be nested and styled. ---
    Loading...
    Loading...
    Loading...
    --- ### Custom filters To filter a column with a *`columnName`* : 1. HTML: add `ng-template` with `cTemplateId="columnFilter_`*`columnName`*`"` with _your component_ 2. TypeScript: create `filterFunction` and pass it to the `columnFilterValue` prop of `c-smart-table` component ##### Custom filter with MultiSelect ---
    Loading...
    Loading...
    Loading...
    --- ##### Custom filter with Date Range Picker ---
    Loading...
    Loading...
    Loading...
    --- ### Custom functions ##### Custom filter/sorter functions with nested data column ---
    Loading...
    Loading...
    Loading...
    Loading...
    --- ##### Custom filter/sorter functions with `tableData` template aggregated columns
    ~5.2.19
    ---
    Loading...
    Loading...
    Loading...
    Loading...
    --- ### Summary row - Starting from
    ~4.5.26
    you can pass an ng-template with `cTemplateId="tableSummaryRow"` as a c-smart-table content. - Style `tr` and `th` elements according to your needs. Display any data you want. ---
    Loading...
    Loading...
    Loading...
    Loading...
    ### External data One of the key features of **CoreUI Angular Smart Table** (Angular DataTable) is the ability to load data from an external source, such as an API or a server-side script. This can be useful if you have a large amount of data that you don't want to load all at once, or if you want to allow users to interact with the data without having to reload the page. Use the `HttpClient` for communication with the data source, and _get_ the external data from backend into a CoreUI Angular Smart Table (Angular DataTable). Here is an example of how you might use CoreUI Angular Smart Table with external data (**10.000+ records**):
    Loading...
    Loading...
    Loading...
    Loading...
    --- ## API ### SmartTable Module
    ### SmartTable Standalone
    --- ### c-smart-table _component_ #### Inputs
    | name | description | type | default | | ---- | ----------- | ---- | ------- | | `activePage` | Current page number | `number` | _1_ | | `cleaner` | Displays table cleaner above table. Cleaner resets `tableFilterValue`, `columnFilterValue`, `sorterValue`. If clean is possible it is clickable, otherwise it is not clickable and transparent. Cleaner can be customized through the cleaner slot. | `boolean` | _false_ | | `clickableRows` | Style table items as clickable. | `boolean` | _false_ | | `columnFilter` | Displays additional filter row between table header and items, allowing filtering by specific column. | `boolean \| IColumnFilter` | _undefined_ | | `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 }`. | `IColumnFilterValue` | _{ }_ | | `columns` | (1) Table columns configuration. If not defined, table displays columns based on the first item keys, omitting keys that begins with underscore (e.g. '_classes') | `(string \| IColumn)[]` | _undefined_ | | `columnSorter` | (2) Enables table sorting by column value. Sorting will be performed correctly when values in a column are of one type: `string` (case insensitive) or `number`. | `boolean \| ISorter` | _undefined_ | | `footer` | Displays table footer, which mirrors table header. (without column filter). | `boolean` | _false_ | | `header` | Displays table header. | `boolean` | _false_ | | `items` | (3) Array of objects, where each object represents one item - row in table. | `IItem[]` | _[]_ | | `itemsPerPage` | Number of items per site, when pagination is enabled. | `number` | _10_ | | `itemsPerPageLabel` | Label for items per page selector. | `string` | _Items per page:_ | | `itemsPerPageOptions` | Items per page selector options. | `number[]` | _[5, 10, 20, 50]_ | | `itemsPerPageSelect` | Adds select element over table, which is used for control items per page in pagination. | `boolean \| ItemsPerPageSelect` | _undefined_ | | `loading` | When set, table will have loading style: loading spinner and reduced opacity. When 'small' prop is enabled spinner will be also smaller. | `boolean` | _undefined_ | | `noItemsLabel` | String for passing custom noItemsLabel text. | `string` | _No items found_ | | `pagination` | Enables default pagination. 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 pagination instead. | `boolean` | _false_ | | `selectable` | Add checkboxes to make table rows selectable. | `boolean` | _false_ | | `selectAll`
    4.5.26+
    | Enable / disable "select all" checkbox displayed in the header of the table. | `boolean` | _true_ | | `sorterValue` | State of the sorter. Name key is column name, direction can be 'asc' or 'desc'. | `ISorterValue` | _{ }_ | | `tableFilter` | (4) When set, displays table filter above table, allowing filtering by specific column. | `boolean \| ITableFilter` | _undefined_ | | `tableFilterLabel` | A label for a tableFilter input. | `string` | _Filter:_ | | `tableFilterPlaceholder` | Specifies a short hint that is visible in the search input. | `string` | _Type string..._ | | `tableFilterValue` | Value of table filter. | `string` | _''_ | | `tableBodyProps` | Properties for tbody | `ITableGroupProps` | _{ }_ | | `tableFootProps` | Properties for tfoot. | `ITableGroupProps` | _{ }_ | | `tableHeadProps` | Properties for thead. | `ITableGroupProps` | _{ }_ | | `tableProps` | Properties for cTable. | `ITable` | _{ }_ |
    --- (1) In `columns` array each 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. - `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. - `_classes` (String/Array/Object) - adds classes to all cells in a column - `_style` (String/Array/Object) - adds styles to the column header (useful for defining widths) - `_props` - (Object) - adds props for a column header - `sorter` (Boolean/CompareFn(a,b) => number) - disables sorting of the column when set to false. See also: CompareFn - `filter` (Boolean/FilterFn(item, value: string) => boolean) - removes filter from column when set to false (2) Sorter can be customized, by passing prop as object with additional options as keys. Available options: - external (Boolean) - Disables automatic sorting inside component. - resettable (Boolean) - If set to true, clicking on sorter have three states: ascending, descending and null. That means that third click on sorter will reset sorting, and restore table to original order. (3) Example item: `{ name: 'John' , age: 12, _selectable: false, _props: { color: 'success' }, _cellProps: { age: { active: true, align: 'middle'}}}` For column generation description see columns prop. (4) Column filter can be customized, by passing prop as object with additional options as keys. Available options: - placeholder (String) - Sets custom table filter placeholder. - label (String) - Sets custom table filter label. - external (Boolean) - Disables automatic filtering inside component. - lazy (Boolean) - Set to true to trigger filter updates only on change event. --- #### Outputs
    | name | description | type | notes | | ---- | ----------- | ---- | ----- | | `activePageChange` | Event emitted on `activePage` change | `number` | | `cleanerClick` | Event emitted on cleaner click | |v5.4.12+ | | `columnFilterValueChange` | Event emitted on `columnFilterValue` change | | | `filteredItemsChange` | Event emitted on `filteredItems` change | | | `itemsPerPageChange` | Event emitted on `itemsPerPage` change | | | `rowClick` | Event emitted on row click | | | `selectedItemsChange` | Event emitted on `selectedItems` change | | | `sorterValueChange` | Event emitted on `sorterValue` change | | | `tableFilterValueChange` | Event emitted on `tableFilterValue` change | |
    ## Templates You can pass an ng-template with cTemplateId as a c-smart-table content. Available templates with [cTemplateId] names: - `tableCustomHeader` (
    ~4.4.5
    goes to the header row with table filter/cleaner) - `tableData` (goes to `td` html element for specified `columnName`) - `tableDetails` (goes to separate row as row details, for every `tr`) - `tableSummaryRow` (
    ~4.5.26
    goes to the table footer) - `columnFilter_*` (see: [Custom Filters](components/smart-table#custom-filters)) - `columnLabel_*` (
    ~4.7.7
    see: [Custom Headers](components/smart-table#custom-headers))
    All templates are optional. To use custom templates you'll have to: - `import {SharedModule} from '@coreui/angular'` - pass the template name as a string to `[cTemplateId]` directive For `tableData` pass the following variables: - `columnName` ('key' - derived from [columns] definition) - `item` (current row of [items] data array) - `tdContent` (default content for every column of a current row)
    ```html
    <ng-template
      cTemplateId="tableData"
      let-columnName="columnName"
      let-item="item"
      let-tdContent="tdContent"
    >
        ...
    </ng-template>
    ```
    
    Having columnName you can `ngSwitch` for custom rendering specified columns. Do not forget about `ngSwitchDefault` with `tdContent`. Also - SmartTableComponent has exportAs: `cSmartTable` that you can use as a template variable (#smartTable in the example) - SharedModule - [cTemplateId] - ButtonModule - [cButton] - TableModule - [cTableActive], [cTableColor] - UtilitiesModule - [cAlign]
    • Twitter
    • Support
    • CoreUI (Vanilla)
    • CoreUI for React.js
    • CoreUI for Vue.js

    CoreUI for Angular is Open Source UI Components Library for Angular.

    Currently v5.4.12 Code licensed MIT , docs CC BY 3.0 .
    CoreUI PRO requires a commercial license.