From fc46830f7d9c8973b73bb24e0d0989120e9b5c9d Mon Sep 17 00:00:00 2001 From: Denys Vuika Date: Mon, 14 Aug 2017 11:26:36 +0100 Subject: [PATCH] [ADF-1021] custom tooltip formatter for data columns (#2206) * custom tooltip formatter for data columns * readme updates * unit tests --- .../app/components/files/files.component.html | 7 +- .../app/components/files/files.component.ts | 8 ++ .../data-column/data-column.component.ts | 4 +- .../ng2-alfresco-datatable/README.md | 34 +++++++ .../datatable/datatable.component.html | 6 +- .../datatable/datatable.component.spec.ts | 37 +++++++ .../datatable/datatable.component.ts | 10 ++ .../src/data/datatable-adapter.ts | 1 + .../src/material.module.ts | 11 ++- .../ng2-alfresco-documentlist/README.md | 96 +++++++++++++------ 10 files changed, 175 insertions(+), 39 deletions(-) diff --git a/demo-shell-ng2/app/components/files/files.component.html b/demo-shell-ng2/app/components/files/files.component.html index 6d9dda7dae..d94a188f31 100644 --- a/demo-shell-ng2/app/components/files/files.component.html +++ b/demo-shell-ng2/app/components/files/files.component.html @@ -102,9 +102,10 @@ class="image-table-cell"> + title="{{'DOCUMENT_LIST.COLUMNS.DISPLAY_NAME' | translate}}" + key="name" + [formatTooltip]="getNodeNameTooltip" + class="full-width ellipsis-cell"> - + ``` 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. @@ -567,12 +568,12 @@ context.row.getValue('createdByUser.displayName') You may want using **row** api to get raw value access. ```html - - - + + ``` Use **data** api to get values with post-processing, like datetime/icon conversion._ @@ -580,25 +581,25 @@ Use **data** api to get values with post-processing, like datetime/icon conversi In the Example below we will prepend `Hi!` to each file and folder name in the list: ```html - - - + + ``` In the Example below we will add the [ng2-alfresco-tag](https://www.npmjs.com/package/ng2-alfresco-tag) component is integrate in the document list. ```html - - - + + ``` ![Tag component in document List](docs/assets/document-list-tag-template.png) @@ -938,6 +939,39 @@ DocumentList emits the following events: ## Advanced usage and customization +### 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 'ng2-alfresco-datatable'; + +@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. + ### Custom row filter You can create a custom row filter implementation that returns `true` if row should be displayed or `false` to hide it.