---
Added: v2.0.0
Status: Active
---
# DataColumn Component
Defines column properties for DataTable, Tasklist, Document List and other components.
## Contents
- [Basic Usage](#basic-usage)
- [Properties](#properties)
- [Details](#details)
- [Automatic column header translation](#automatic-column-header-translation)
- [Custom tooltips](#custom-tooltips)
- [Column Template](#column-template)
- [Styling Techniques](#styling-techniques)
- [See also](#see-also)
## Basic Usage
```html
```
### Properties
| Name | Type | Default value | Description |
| ---- | ---- | ------------- | ----------- |
| key | `string` | | Data source key. Can be either a column/property key like `title` or a property path like `createdBy.name`. |
| type | `string` | `'text'` | Value type for the column. Possible settings are 'text', 'image', 'date', 'fileSize' and 'location'. |
| format | `string` | | Value format (if supported by the parent component), for example format of the date. |
| sortable | `boolean` | `true` | Toggles ability to sort by this column, for example by clicking the column header. |
| title | `string` | `''` | Display title of the column, typically used for column headers. You can use the i18n resource key to get it translated automatically. |
| formatTooltip | `Function` | | Custom tooltip formatter function. |
| srTitle | `string` | | Title to be used for screen readers. |
| cssClass | `string` | | Additional CSS class to be applied to column (header and cells). |
## Details
### Automatic column header translation
You can use i18n resource keys with DataColumn `title` property.
The component will automatically check the corresponding i18n resources and fetch corresponding value.
```html
```
This feature is optional. Regular text either plain or converted via the `translate` pipe will still be working as it was before.
### Custom tooltips
You can create custom tooltips for the table cells by providing a `formatTooltip` property with a tooltip formatter function when declaring a data column.
```html
```
And the code in this case will be similar to the following:
```ts
import { DataColumn, DataRow } from '@alfresco/adf-core';
@Component({...})
export class MyComponent {
...
getNodeNameTooltip(row: DataRow, col: DataColumn): string {
if (row) {
return row.getValue('name');
}
return null;
}
}
```
To disable the tooltip your function can return `null` or an empty string.
### Column Template
You can provide custom column/cell templates that may contain other Angular components or HTML elements:
Every cell in the DataTable component is bound to the dynamic data context containing the following properties:
| Name | Type | Description |
| ---- | ---- | ----------- |
| data | [DataTableAdapter](datatable-adapter.interface.md) | Data adapter instance. |
| row | [DataRow](datatable-adapter.interface.md) | Current data row instance. |
| col | [DataColumn](datatable-adapter.interface.md) | Current data column instance. |
You can use all three properties to gain full access to underlying data from within your custom templates.
In order to wire HTML templates with the data context you will need defining a variable that is bound to `$implicit` like shown below:
```html
```
The format of naming is `let-VARIABLE_NAME="$implicit"` where `VARIABLE_NAME` is the name of the variable you want to bind template data context to.
Getting a cell value from the underlying DataTableAdapter:
```ts
context.data.getValue(entry.row, entry.col);
```
You can retrieve all property values for underlying node, including nested properties (via property paths):
```ts
context.row.getValue('name')
context.row.getValue('createdByUser.displayName')
```
You may want using **row** api to get raw value access.
```html
Hi! {{context.row.getValue('createdByUser.displayName')}}
Hi! {{context.row.getValue('name')}}
```
Use **data** api to get values with post-processing, like datetime/icon conversion.\_
In the Example below we will prepend `Hi!` to each file and folder name in the list:
```html
Hi! {{entry.data.getValue(entry.row, entry.col)}}
```
In the Example below we will integrate the [adf-tag-node-list](tag-node-list.component.md) component
with the document list.
```html
```

### Styling Techniques
You can add a custom CSS class to a column using its `class` property. This is useful for
many purposes - some examples are given below.
#### Custom icons for selected rows
Custom styling can be used to change the look and feel of the icon for the selected rows.
Let's start by assigning an "image-table-cell" class to the thumbnail column:
```html
...
```
Now your application can define styles to change the content of the column based on conditions such as the selection state:
```css
adf-document-list ::ng-deep adf-datatable > table > tbody > tr.is-selected > td.adf-data-table-cell.adf-data-table-cell--image.image-table-cell > div > div > mat-icon > svg {
fill: #00bcd4;
}
```
Once your application starts you should see the following icon for each selected row:

#### Hiding columns on small screens
You can hide columns on small screens using custom CSS rules:
```css
@media all and (max-width: 768px) {
alfresco-document-list ::ng-deep th.desktop-only .cell-value {
display: none;
}
alfresco-document-list ::ng-deep td.desktop-only .cell-value {
display: none;
}
}
```
Now you can declare columns and assign `desktop-only` class where needed:
```html
```
**Desktop View**

**Mobile View**

## See also
- [Document list component](document-list.component.md)
- [Datatable component](datatable.component.md)
- [Task list component](task-list.component.md)