CoreUI Angular Logo
Framework:
  • JavaScript / Vanilla JS
  • React.js
  • Vue.js
Getting startedIntroductionSupport CoreUICustomizeSassOptionsCSS VariablesLayoutBreakpointsContainersGridColumnsGuttersFormsOverviewDate PickerPRODate Range PickerPROForm ControlSelectMulti SelectPROChecks & RadiosPassword InputPRORangeRange SliderPRORatingPROStepperPROInput GroupFloating LabelsLayoutTime PickerPROValidationComponentsAccordionAlertAvatarBadgeBreadcrumbButtonButton GroupCalendarPROCalloutCardCarouselClose buttonCollapseDropdownFooterHeaderImageList GroupLoading ButtonPROModalNavNavbarOffcanvasPaginationPlaceholderPopoverProgressSmart PaginationPROSmart TablePROSidebarSpinnerTableTabsNewToastTooltipWidgetsIconsChartsTemplatesNewAdmin & DashboardDownloadInstallationCustomizeContentMigrationv4 → v5v3 → v4Angular version


DownloadHire UsGet CoreUI PRO
On this page
    CoreUI PRO for Angular This 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.

    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

    Name
    Registered
    Role
    Status
    Derick Maximinus 2022/03/01 Member Pending
    Derick Maximinus

    User since: 2022/03/01

    Ebbe Gemariah 2022/02/08 Admin Inactive
    Ebbe Gemariah

    User since: 2022/02/08

    Enéas Kwadwo 2022/03/01 Member Pending
    Enéas Kwadwo

    User since: 2022/03/01

    Estavan Lykos 2022/02/01 Staff Banned
    Estavan Lykos

    User since: 2022/02/01

    Eustorgios Amulius 2022/03/01 Member Pending
    Eustorgios Amulius

    User since: 2022/03/01

    Name
    Registered
    Role
    Status
    Loading...
    Loading...
    Loading...

    Default header

    • labels generation based on column names

    Id
    Name
    Registered
    Role
    Status
    10 Agapetus Tadeáš 2022/01/21 Staff Active
    11 Carwyn Fachtna 2022/01/01 Member Active
    12 Nehemiah Tatius 2022/02/11 Staff Banned
    13 Ebbe Gemariah 2022/02/08 Admin Inactive
    14 Eustorgios Amulius 2022/03/01 Member Pending
    15 Leopold Gáspár 2022/01/21 Staff Active
    16 Pompeius René 2022/01/10 Member Active
    17 Paĉjo Jadon 2022/02/01 Staff Banned
    18 Micheal Mercurius 2022/02/11 Admin Inactive
    19 Ganesha Dubhghall 2022/03/01 Member Pending
    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

    Name
    Role
    Status
    John Doe Guest Pending 2022/01/01
    Samppa Nori Member Active 2022/01/31
    Estavan Lykos Staff Banned 2022/02/01
    Chetan Mohamed Admin Inactive 2022/02/01
    Derick Maximinus Member Pending 2022/03/01
    Friderik Dávid Staff Active 2022/01/21
    Yiorgos Avraamu Member Active 2022/01/07
    Avram Tarasios Staff Banned 2022/02/08
    Quintin Ed Admin Inactive 2022/02/01
    Enéas Kwadwo Member Pending 2022/03/01
    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.


    Main Group
    Subgroup 1 Subgroup 2
    Long and overflowing header label caption
    Registered
    Role
    Status
    Agapetus Tadeáš 2022/01/21 Staff Active
    Carwyn Fachtna 2022/01/01 Member Active
    Nehemiah Tatius 2022/02/11 Staff Banned
    Ebbe Gemariah 2022/02/08 Admin Inactive
    Eustorgios Amulius 2022/03/01 Member Pending
    Leopold Gáspár 2022/01/21 Staff Active
    Pompeius René 2022/01/10 Member Active
    Paĉjo Jadon 2022/02/01 Staff Banned
    Micheal Mercurius 2022/02/11 Admin Inactive
    Ganesha Dubhghall 2022/03/01 Member Pending
    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

    Name
    Role
    no items
    John Doe Guest
    Samppa Nori Member
    Estavan Lykos Staff
    Chetan Mohamed Admin
    Derick Maximinus Member
    Friderik Dávid Staff
    Yiorgos Avraamu Member
    Avram Tarasios Staff
    Quintin Ed Admin
    Enéas Kwadwo Member
    Loading...
    Loading...

    Custom filter with Date Range Picker

    Name
    Registered
    Mon
    Tue
    Wed
    Thu
    Fri
    Sat
    Sun
    27
    28
    29
    30
    31
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    1
    2
    3
    4
    5
    6
    John Doe 2022/01/01
    Carwyn Fachtna 2022/01/01
    Vishnu Serghei 2022/01/01
    Aulus Agmundr 2022/01/01
    Yiorgos Avraamu 2022/01/07
    Pompeius René 2022/01/10
    Loading...
    Loading...

    Custom functions

    Custom filter/sorter functions with nested data column

    Name
    Address
    City
    John Doe France Paris
    Samppa Nori Chile Santiago
    Estavan Lykos Germany Berlin
    Chetan Mohamed Germany Berlin
    Derick Maximinus Chile Santiago
    Friderik Dávid France Paris
    Yiorgos Avraamu Chile Concepción
    Avram Tarasios Chile Santiago
    Quintin Ed France Lyon
    Enéas Kwadwo Chile Santiago
    Loading...
    Loading...
    Loading...

    Custom filter/sorter functions with tableData template aggregated columns
    ~5.2.19


    User
    Country
    Email
    No items found
    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.

    Name
    Registered
    Role
    Status
    John Doe 2022/01/01 Guest Pending
    Samppa Nori 2022/01/31 Member Active
    Estavan Lykos 2022/02/01 Staff Banned
    Chetan Mohamed 2022/02/01 Admin Inactive
    Derick Maximinus 2022/03/01 Member Pending
    Selected: 0. Items count: 25.
    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...

    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)
    • columnLabel_* (
      ~4.7.7
      see: 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)
    <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]
    • GitHub
    • 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.5.2 Code licensed MIT , docs CC BY 3.0 .
    CoreUI PRO requires a commercial license.