Files
alfresco-ng2-components/docs/datatable.component.md
T
Eugenio Romano 43032c7fd7 2.1.0 (#2891)
* adf-insights 2.0.1

* update script

* [ADF-2048] Fixed corrupted link in User Guide (#2757)

* [ADF-1752] disable completely sidebar when allowSidebar option is false (#2753)

* [ADF-1752] disable completely sidebar when allowSidebar option is false

* [ADF-1752] improved condition for showing toolbar

* support for explicit viewer type for URL (#2688)

* Fix line clamp temporary (#2747)

* Adding automation-id to search-control component (#2759)

* [ADF-2025] Task List - The pagination should be fetched from the UserPreference (#2733)

[ADF-2025] Task List - The pagination should be fetched from the UserPreference

* Update viewer documentation (#2763)

* [ADF-1431] Destination Picker: Display path of the folder in search results (#2762)

* Add initial implementation with style fixes

* Further style fixes

* Add tests, styling fixes

* Fix the title of Model column in ECM License datatable. (#2770)

* [ADF-1826] Task Header - The priority property should be editable (#2768)

* [ADF-1826] Task Header - The priority property should be editable

* [ADF-1826] - Fixed isEditble typo

* [ADF-1826] - Adding unit test - checking the priority value is displayed

* [ADF-1826] fixed unit test

* [ADF-1826] fixed unit test (replaced fit with it)

* [ADF-2056] update dependencies (#2764)

* update dependencies
add ban for fdescribe in tslint
reenable test
add badge codacy
check bundles esm5 and esm2015
travis run new vuild script

* remove fdescribe

* material 5.0.0 stable release

* comment out test service under should return the task details

* [ADF-2051] Involve people name is not displayed properly. (#2773)

This issue is now fixed

* [ADF-2061] Fix content node selector search (#2772)

* Fix content node selector search

* Fix tests

* [ADF-2069] Error is displayed on console when adding a description to a task. (#2779)

* Fixed the console error coming while adding description or priority in task details

* special CSS class if pagination is empty (#2780)

* add missing exports (#2782)

* [ADF-2065] Refactored Content node selector component  (#2778)

* [ADF-2065] created dialog component for content node selector

* [ADF-2065] removing SiteModel from site dropdown to use SitePaging model of js-api

* [ADF-2065] - removed site model and updated documentation

* [ADF-2065] fixed test for site component

* [ADF-2065] refactored content node selector and created content node selector dialog

* [ADF-2065] fixed test on site-api service

* [ADF-2065] added a new content node dialog service to centralise the logic for content node dialog

* [ADF-2065] start adding test for node-actions service|

* [ADF-2065] added test for node-actions service

* [ADF-2065] added test for node action service

* [ADF-2065] renamed components to keep backward compatibility

* [ADF-2065] added input just for backward compatibility

* [ADF-2065] added some changes for backward compatibility and updated documentation

* [ADF-2065] updated documentation for content node selector

* add missing exports (#2784)

* [ADF-2102] Task List - Provide a way to support custom html template and static columns at same time (#2787)

* * Removed unused adf-task-list keys from app.config
* Fix can add/remove the static property through the app.config and can put custom columns into the html in adf-tasklist component

* Fix add/remove the static property through the app.config and can put custom columns into the html in adf-tasklist component

* * Fixed support custom html template and static columns.
* Updated tasklist doc.
* Fixed failing test case.

* * Fixed support custom html template and static columns

* * Updated task-list documentation.

* [ADF-2094] Task Form - Doesn't follow the specification (#2786)

* [ADF-2094] Task Form - Doesn't follow the specification

* Removed icon visible beside title

* Made font-size for title as semibold 20px

* Set the outcome buttons on bottom right side

* set color of Complete button as primary

* [ADF-2094] Task Form - Doesn't follow the specification
* Changed the css for the Adf-form according to zeplin design

* Removed icon visible beside title

* Made font-size for title as semibold 20px

* Set the outcome buttons on bottom right side

* set color of Complete button as primary

* [ADF-2094] Task Form - Doesn't follow the specification

* Changed the css for the adf-form according to zeplin design

* Removed icon visible beside title

* Made font-size for title as semibold 20px

* Set the outcome buttons on bottom right side

* set color of Complete button as primary

* [ADF-2103] Info Drawer - Provide a way to select a different tab (#2788)

* Provide a way to select a different tab

* Fix the default value

* Override the value through the html

* fix different material depencncies (#2791)

* [ADF-2070][ADF-2071][ADF-2072] 'Load more' on destination picker does… (#2774)

* [ADF-2070][ADF-2071][ADF-2072] 'Load more' on destination picker doesn't display correct content of folders

* [ADF-2070][ADF-2071][ADF-2072] add tests

* [ADF-2070][ADF-2071][ADF-2072] 'Load more' on destination picker doesn't display correct content of folders

* [ADF-2102] Task List - Provide a way to support custom html template and static columns at same time (#2793)

* Removed lodash import from tasklist component.
* Refactored getschema method.

* [ADF-2067] Not able to see the 'My tasks' filter when clicking on a newly created app. (#2792)

* fixed Not able to see the 'My tasks' filter when clicking on a newly created app.
* Create default services return response with id.

* [ADF-2098] Start Process - the default process definition should be selected  (#2794)

* [ADF-2098] Start Process - the default process definition should be selected

* made the start-process component to automatically select Process definition if it is the only definition.

* [ADF-2098] Start Process - the default process definition should be selected

* made the start-process component to automatically select a processDef in start-form if there just one processDef present

* [ADF-2098] Start Process - the default process definition should be selected

* made the start-process component to automatically select a processDef in start-form if there just one processDef present

* Update start-process.component.html

* Update start-process.component.ts

* Fix adf is not defined for customStencil (#2795)

* [ADF-2109] Task Form - The form doesn't fit in the mobile screen (#2797)

* [ADF-2109] Task Form - The form doesn't fit in the mobile screen

* Made form mobile compatible

* Fixed issues arising due to the issue ADF-2094

* [ADF-2109] Task Form - The form doesn't fit in the mobile screen

* Made adf form mobile compatible

* Fixed issues arising due to the issue ADF-2094

* [ADF-2095] Start Task - The start button should have the primary colour (#2799)

* [ADF-2095] Start Task - The start button should have the primary colour.

* fixed start button should have the primary colour.

* [ADF-2095] Start Task/Process - The start button should have the primary colour.

*  fixed start button should have the primary colour and Uppercase.

* * Start task button should have the primary colour

* [ADF-1958] Process Attachment list - The empty list should be a simpl… (#2798)

* [ADF-1958] Process Attachment list - The empty list should be a simple template

* changed the default empty list to a simple template

* changed process-attachment.component.html so that the user can pass custom empty tempate

* [ADF-1958] Process Attachment list - The empty list should be a simple template

* changed the default empty list to a simple template

* changed process-attachment.component.html so that the user can pass custom empty tempate

* removed some unused variables

* [ADF-1958] Process Attachment list - The empty list should be a simple template

* changed the default empty list to a simple template

* changed process-attachment.component.html so that the user can pass custom empty tempate

* [ADF-2119] Document List - The pagination should be fetched from the UserPreference (#2801)

* Changed the service fetching page sizes in document-list component

* uncommented a line in process-service.component.ts for the tasklist to show page-sizes in task-list

* [no-issue] docker file (#2800)

* docker file

* cache busting for translation files (#2804)

* [ADF-1999] i18n support for file size pipe (#2803)

* i18n support for fileSize pipe

* remove unused declaration

* update unit test

* fix documentation theming

* docker nginx fix

* documentation updates (#2806)

* viewer styling improvements (#2805)

* add missing headless chrome setup for Travis (#2807)

* [ADF-2127] Started introducing new doc tools (#2809)

* try to revert karma change

* [fix-build] add stable version chrome in travis conf (#2819)

* chrome stable

* No input and No Output rename tslint rule (#2814)

* [ADF-1999] fix file size translation for 0 bytes (#2817)

* fix file size translation for 0 bytes

* update translation mock

* [ADF-2135] Updated tables of contents and tools (#2820)

* [ADF-1986] Content matadata editing phase II. (#2796)

* Aspects collection

* Fetch only those metadata aspects which are defined in the application config

* Aspect property filtering first round

* Addig wildcard support for preset, default preset fallback to wildcard, and logging

* Add white list service

* Renaming services

* ContentMetadataService and CardViewItemDispatcherComponent update

* Observables... Observables everywhere...

* Propers CardViewAspect

* Defining more interfaces

* Dummy data and expansions panels

* Fix build attempt & proper panel expansion

* Folder restructuring

* Add different type mappings

* Restructuring Card view component

* Fix build

* More ECM types supported

* Validators first phase, extraction of interfaces, world domination preparation

* Validators phase II.

* Integer and float validators

* Hide empty text items and validation message foundation

* Validation error messages for text item view, small style changes

* Update date item

* bool item component

* Datetimepicker npm module

* Datetime model

* Add mapping for datetime

* Small fixes

* Passing down preset

* Adding forgotten package.json entry

* Adding some tests for wrapper card component

* content-metadata.component tests

* Covering some edge cases, adding some tests

* Fix cardview component's test

* Add datetimepicker to demoshell

* card view component show empty values by default

* displayEmpty dependency injection

* remove table like design from cardview

* Using alfresco-js-api instead of spike

* Remove spike folder and contents

* Fix test

* Cardview updated docs

* Content metadata md

* Fix review issues

* Fix the packagr issue

* [ADF-2097] Sidebar Action Menu - New component (#2813)

SidebarMenu Component

* [no-issue] downgrade scss bundle and some other minor fix (#2824)

* downgrade scss bundle and some other minor fix

* 2.0.9

* remove chrome in travis conf

* execute different configuration

* [ADF-1769] Added JSDoc for components (#2823)

* [ADF-1769] Added JSDoc for components

* [ADF-1769] Fixed tslint error with trailing whitespace

* [ADF-2135] Updated tables of contents (#2822)

* [ADF-2054] Created a new widget to handle uploading file from Share (#2810)

* [ADF-2054] start creating custom upload widget for share integration

* [ADF-2054] changed content node selector service to allow different opening approach

* [ADF-2054] addedd support for multi resource files

* [ADF-2054] fixed base case for upload when only local files are selected

* [ADF-2054] start adding and fixing tests for new share attach button widget

* [ADF-2054] changed test to perfrom a correct check

* [ADF-2054] removed fdescribe

* [ADF-2054] added test for share-widget component

* [ADF-2054] added peer reviews changes

* [ADF-2054] created a module folder for content widgets

* [ADF-2054] fixed wrong import

* [ADF-2054] fixed rebase errors

* [ADF-2054] restored some files changed by rebase

* [ADF-2054] added link to content services to fix packaging issue

* [ADF-2054] renamed widget

* [ADF-2136] support shared links and renditions in the Viewer (#2826)

* support previewing shared link content

* remove unused router instance

* docs update

* support 'shared links' preview in the Viewer

* fallback to image preview if PDF rendition now available (#2827)

* contentActions enabling properties

* [contextMenuActions]="true" properties documentation

* [ADF-2172]Adding data-automation-id for create task/process button (#2828)

* [ADF-2152] Updated See Also sections in docs (#2830)

* [ADF-1769] Updates to prop table script (#2829)

* [ADF-1769] Fixed prop table tool formatting

* [ADF-1769] Added code style to event type column

* [ADF-2148] Update the angular and material libraries to the latest version (#2821)

* Update the angular and material library to the latest version

* [ADF-325] added attach folder widget (#2831)

[ADF-325] added new attach folder widget

*  [ADF-2053] improved search result adding refresh on delete (#2836)

* [ADF-2053] refreshed results when folder is deleted

* [ADF-2053] improved search result adding refresh on delete

* [ADF-2053] added missing whitespace

* [ADF-2120] added page size retrieving from user preference on demo shell (#2837)

* [ADF-2152] Added See Also sections and updated doc tools (#2835)

* [ADF-2152] Added See Also sections to docs

* [ADF-2152] Added doc script to package.json

* [ADF-2162] Added screenshot for Notification service (#2843)

* Fix mobile media query (#2840)

* Remove wrapping form datatable header (#2841)

* [ADF-2152] Updated See Also sections in docs (#2842)

* [ADF-2055] Ability to pre-populate form with a file and values (#2834)

* fix translations form

* fix style webpack script

* fix tslint error problem in viewer

* fix naming problems in attach file widget

* add start process form values data initialization option

* fix translation problems

* missing return type

* start process name configuration

* add CS cross PS configuration

* start process from file example

* fix minor issues

* add documentation and move the dialog in a separate component

* easy test select app

* alfrescoRepositoryName right property

* file conversion test

* fix issue after CR

* Remove forgotten semicolon.

* Fix default translation key (#2844)

* [ADF-1769] Added JSDocs and updated prop table script (#2838)

* [ADF-1769] Added JSDocs and updated prop table script

* [ADF-1769] Fixed lint error in JSDoc

* [ADF-2152] Updated See Also sections in docs (#2846)

* Add soem more explanation in the search autocomplete binding

* Rollback the upgrade libs (#2850)

* [ADF-1880] processDefinitionId parameter in adf-start-process (#2848)

* processDefinitionId parameter in adf-start-process

* fix test

* fix test

* Add @angular-devkit/core as dev dependency (#2853)

* [ADF-2183] fixed translation on no permission tooltip (#2857)

* Fix localisation in Datetimepicker (#2851)

* [ADF-2157] Infinite pagination target supporting (#2856)

* Infinite pagination target supporting

* Updating documentation

* [ADF-1769] Updated prop table script to handle inherited classes (#2855)

* [ADF-2170] fixed condition for file size equal zero (#2860)

* [ADF-2170] fixed condition for file size equal zero

* [ADF-2170] refactored if condition

* [ADF-2186] Update calculated properties on node change in content metadata compo… (#2862)

* Update calculated properties on node change in content metadata component

* Add module to public api

* [ADF-2160] Improved combined action info in Content Action component docs (#2861)

* remove processInstanceId reset (#2847)

* [ADF-2150] improved queryBody mechanism (#2852)

* [ADF-2150] changed query body parameter to a function

* [ADF-2150] added an example page where to try change query body

* [ADF-2150] improved queryBody mechanism

* [ADF-2150] fixed content node test

* [ADF-2150] extended docs added another way to use the query node

* [ADF-2150] fixed test for search on content node

* [ADF-2150] added some improvements to service config

* [ADF-2150] changed the documentation accordingly

* [ADF-2150] added PR changes

* [ADF-2150] fixed jdoc

* [ADF-2150] added checkbox to switch from service approach to input object approach

* [ADF-2150] fixed build error on demo shell

* style fixes for viewer (#2858)

* style fixes for viewer

* use theme colors

* initial theme support for PDF viewer

* [ADF-2196] fixed error message for no permission on copy and move (#2863)

* [ADF-2196] fixed error message for no permission on copy and move

* [ADF-2196] removed fdescribe

* Fix missing translation (#2867)

* Fix sidebar node reloading issue (#2866)

[ADF-2186] Fix sidebar node reloading issue

* [ADF-2201] Tidied Start Process docs (#2864)

* [ADF-2201] Tidied Start Process docs

* [ADF-2201] Removed file with probably incorrect name

* [ADF-2174] Menus background color is not properly displayed in black themes (#2859)

* [ADF-2174] Menus background color is not properly displayed in black themes

* Removed global mat-menu-panel class style overriding

* * Refactored styles

* * Changed opacity property to rgba so that injected coponents will not be affected

* Removed fixed menu width

* [ADF-2201] Tidied Content Node Dialog docs (#2870)

* Fix margin top (#2875)

* Fix dynamic table css (#2879)

* [ADF-1880] More configuration options for adf-start-process component (#2869)

* procesdefinitionId set
show dropdown multiple process

* fix sourcemap

* fix test start process

* fix test

* changes after code review

* add show dropdown optional

* remove fit fdescribe

* processDefinitionId in processDefinition change

* improve tests

* new i18n file 2.1.0 (#2878)

* [ADF-2201] Search Configuration doc (#2876)

* [ADF-2201] Updated search component docs and tidied index page

* [ADF-2201] Fixed incorrect link

* [ADF-2201] Updated docs based on feedback

* [ADF-2201] Fixed broken relative link

* Update start-process.component.md

* Update start-process.component.md

* [ADF-2201] Updated renditions service docs (#2880)

* [ADF-2208] The width of the 'New Task' option is smaller then Create Task drop down (#2881)

* Set width for menu and button

*  [ADF-2200] fixed problem with redirection url (#2877)

* [ADF-2200] fixed wrong handling of redirectUrl

* [ADF-2200] fixed problem with redirection url

* [ADF-2200] fixed redirection config path

* [ADF-2200] fixed wrong fdescribe test

* [ADF-2200] removed authserviceMock and fixed some tests

* Fix css error (#2882)

* [ADF-2188] Start Process - Change processDefinition property and fix bug (#2884)

* Change processDefinition property and fix bug

* Fix unit test

* Fix async

* Fix id

* [ADF-2200] fixed redirectUrl check (#2886)

* [ADF-2221] Search fails on Content Node Selector (#2888)

* [ADF-2201] Fixed broken links (#2890)

* export material only from the core (#2885)

* Remove app.config reference from doc (#2889)

* update versions to 2.1.0
2018-01-26 16:35:25 +00:00

14 KiB

DataTable component

Displays data as a table with customizable columns and presentation.

DataTable demo

See it live: DataTable Quickstart

Contents

Basic usage

app.component.html

<adf-datatable 
    [data]="data">
</adf-datatable>

app.component.ts

import { ObjectDataTableAdapter }  from '@alfresco/adf-core';

@Component({...})
export class DataTableDemo {
    data: ObjectDataTableAdapter;

    constructor() {
        this.data = new ObjectDataTableAdapter(
            // data
            [
                {id: 1, name: 'Name 1'},
                {id: 2, name: 'Name 2'}
            ],
            // schema
            [
                {
                    type: 'text',
                    key: 'id',
                    title: 'Id',
                    sortable: true
                },
                {
                    type: 'text',
                    key: 'name',
                    title: 'Name',
                    cssClass: 'full-width',
                    sortable: true
                }
            ]
        );
    }
}

You can also use HTML-based schema declaration like shown below:

<adf-datatable [data]="data">
    <data-columns>
        <data-column key="icon" type="image" [sortable]="false"></data-column>
        <data-column key="id" title="Id"></data-column>
        <data-column key="createdOn" title="Created"></data-column>
        <data-column key="name" title="Name" class="full-width name-column"></data-column>
        <data-column key="createdBy.name" title="Created By"></data-column>
    </data-columns>
</adf-datatable>
import { ObjectDataTableAdapter } from '@alfresco/adf-core';

@Component({...})
export class DataTableDemo {
    data: ObjectDataTableAdapter;

    constructor() {
        this.data = new ObjectDataTableAdapter(
            // data
            [
                {
                    id: 1, 
                    name: 'Name 1', 
                    createdBy : { name: 'user'}, 
                    createdOn: 123, 
                    icon: 'http://example.com/img.png'
                },
                {
                    id: 2, 
                    name: 'Name 2', 
                    createdBy : { name: 'user 2'}, 
                    createdOn: 123, 
                    icon: 'http://example.com/img.png'
                }
            ]
        );
    }
}

Properties

Name Type Default Description
selectionMode string 'single' Row selection mode. Can be none, single or multiple. For multiple mode you can use Cmd (macOS) or Ctrl (Win) modifier key to toggle selection for multiple rows.
rowStyle string The inline style to apply to every row, see NgStyle docs for more details and usage examples
rowStyleClass string The CSS class to apply to every row
data DataTableAdapter instance of ObjectDataTableAdapter data source
rows Object[] [] The rows that the datatable should show
multiselect boolean false Toggles multiple row selection, renders checkboxes at the beginning of each row
actions boolean false Toggles data actions column
actionsPosition string (left|right) right Position of the actions dropdown menu.
fallbackThumbnail string Fallback image for row where thumbnail is missing
contextMenu boolean false Toggles custom context menu for the component
allowDropFiles boolean false Toggle file drop support for rows (see ng2-alfresco-core/UploadDirective for more details)
loading boolean false Flag that indicates if the datatable is in loading state and needs to show the loading template. Read the documentation above to see how to configure a loading template
showHeader boolean true Toggles header visibility
selection DataRow[] [] Contains selected rows

Events

Name Description
rowClick Emitted when user clicks the row
rowDblClick Emitted when user double-clicks the row
showRowContextMenu Emitted before context menu is displayed for a row
showRowActionsMenu Emitted before actions menu is displayed for a row
executeRowAction Emitted when row action is executed by user

Details

Supplying data for the table

The column layout and row data are supplied to the table using an object that implements the DataTableAdapter interface. This interface hides the internal details of the class that provides the data, which gives a lot of flexibility in how the data can be stored and accessed. The DataTable library includes a standard adapter class called ObjectDataTableAdapter that is useful for many common uses. See the DataTableAdapter for full details about the interface and the ObjectDataTableAdapter class.

Customizing columns

You can define custom HTML templates for columns and also add tooltips, automatic column title translation and other features. See the DataColumn component page for more information.

DataTable DOM Events

Below are the DOM events raised by DataTable component. These events bubble up the component tree and can be handled by any parent component.

Name Description
row-click Raised when user clicks a row
row-dblclick Raised when user double-clicks a row
row-select Raised after user selects a row
row-unselect Raised after user unselects a row
row-keyup Raised on the 'keyup' event for the focused row.

For example:

<root-component (row-click)="onRowClick($event)">
    <child-component>
        <adf-datatable></adf-datatable>
    </child-component>
</root-component>
onRowClick(event) {
    console.log(event);
}

Custom Empty content template

You can add a template that will be shown when there are no results in your datatable:

<adf-datatable
    [data]="data"
    [actions]="contentActions"
    [multiselect]="multiselect"
    (showRowContextMenu)="onShowRowContextMenu($event)"
    (showRowActionsMenu)="onShowRowActionsMenu($event)"
    (executeRowAction)="onExecuteRowAction($event)"
    (rowClick)="onRowClick($event)"
    (rowDblClick)="onRowDblClick($event)">
    
    
        <no-content-template>
            <!--Add your custom empty template here-->
            <ng-template>
                <h1>Sorry, no content</h1>
            </ng-template>
        </no-content-template>
        
</adf-datatable>

You can use the empty list component if you want to show the default ADF empty template.

You can use any HTML layout or Angular component as a content of the empty template section by using the special <adf-empty-list-header>, <adf-empty-list-body>, <adf-empty-list-footer> elements:

<adf-datatable
    [data]="data"
    [actions]="contentActions"
    [multiselect]="multiselect"
    (showRowContextMenu)="onShowRowContextMenu($event)"
    (showRowActionsMenu)="onShowRowActionsMenu($event)"
    (executeRowAction)="onExecuteRowAction($event)"
    (rowClick)="onRowClick($event)"
    (rowDblClick)="onRowDblClick($event)">
        
        <adf-empty-list>
            <adf-empty-list-header>"'My custom Header'"</adf-empty-list-header>
            <adf-empty-list-body>"'My custom body'"</adf-empty-list-body>
            <adf-empty-list-footer>"'My custom footer'"</adf-empty-list-footer>
            <ng-content>"'HTML Layout'"</ng-content>
        </adf-empty-list>
        
</adf-datatable>
Name Type Default Description
emptyListImageUrl String empty_doc_lib.svg The default image used as background
emptyMsg String This list is empty The default title message
dragDropMsg String Drag and drop The default drag and drop message
additionalMsg String Drag and drop The default additional message

Loading content template

You can add a template that will be shown during the loading of your data:

<adf-datatable
    [data]="data"
    [actions]="contentActions"
    [multiselect]="multiselect"
    [loading]=isLoading()"
    (showRowContextMenu)="onShowRowContextMenu($event)"
    (showRowActionsMenu)="onShowRowActionsMenu($event)"
    (executeRowAction)="onExecuteRowAction($event)"
    (rowClick)="onRowClick($event)"
    (rowDblClick)="onRowDblClick($event)">
    
        <loading-content-template>
            <ng-template>
               <!--Add your custom loading template here-->
                <mat-progress-spinner
                    class="adf-document-list-loading-margin"
                    [color]="'primary'"
                    [mode]="'indeterminate'">
                </mat-progress-spinner>
            </ng-template>
        </loading-content-template>
        
</adf-datatable>
    isLoading(): boolean {
        //your custom logic to identify if you are in a loading state 
    }

Note: the <loading-content-template> and <no-content-template> can be used together

Events

row-keyup DOM event

Raised on the 'keyup' event for the focused row.

This is an instance of the CustomEvent with the details property containing the following object:

row: DataRow,
keyboardEvent: KeyboardEvent,
sender: any

rowClick event

Emitted when user clicks a row.

Event properties:

sender: any     // DataTable instance 
value: DataRow, // row clicked
event: Event    // original HTML DOM event

Handler example:

onRowClicked(event: DataRowEvent) {
    console.log(event.value);
}

This event is cancellable, you can use event.preventDefault() to prevent default behaviour.

rowDblClick event

Emitted when user double-clicks a row.

Event properties:

sender: any     // DataTable instance 
value: DataRow, // row clicked
event: Event    // original HTML DOM event

Handler example:

onRowDblClicked(event: DataRowEvent) {
    console.log(event.value);
}

This event is cancellable, you can use event.preventDefault() to prevent default behaviour.

showRowContextMenu event

Emitted before context menu is displayed for a row.

Note that DataTable itself does not populate context menu items, you can provide all necessary content via handler.

Event properties:

value: {
    row: DataRow,
    col: DataColumn,
    actions: []
}

Handler example:

onShowRowContextMenu(event: DataCellEvent) {
    event.value.actions = [
        { ... },
        { ... }
    ]
}

This event is cancellable, you can use event.preventDefault() to prevent default behaviour.

DataTable will automatically render provided menu items.

See the ContextMenu documentation for more details on context actions format and behaviour.

showRowActionsMenu event

Emitted before actions menu is displayed for a row. Requires actions property to be set to true.

Event properties:

value: {
    row: DataRow,
    action: any
}

Note that DataTable itself does not populate action menu items, you can provide all necessary content via handler.

This event is cancellable, you can use event.preventDefault() to prevent default behaviour.

executeRowAction event

Emitted when a row action is executed by the user.

Usually accompanies showRowActionsMenu event. DataTable itself does not execute actions but provides support for external integration. If there were actions provided with showRowActionsMenu event then executeRowAction will be automatically executed when user clicks corresponding menu item.

<adf-datatable
    [data]="data"
    [multiselect]="multiselect"
    [actions]="true"
    (showRowActionsMenu)="onShowRowActionsMenu($event)"
    (executeRowAction)="onExecuteRowAction($event)">
</adf-datatable>
import { DataCellEvent, DataRowActionEvent } from '@alfresco/adf-core';

onShowRowActionsMenu(event: DataCellEvent) {
    let myAction = {
        title: 'Hello'
        // your custom metadata needed for onExecuteRowAction
    };
    event.value.actions = [
        myAction
    ];
}

onExecuteRowAction(event: DataRowActionEvent) {
    let args = event.value;
    console.log(args.row);
    console.log(args.action);
    window.alert(`My custom action: ${args.action.title}`);
}

Developers are allowed to use any payloads as row actions. The only requirement for the objects is having title property.

Once corresponding action is clicked in the dropdown menu DataTable invokes executeRowAction event where you can handle the process, inspect the action payload and all custom properties defined earlier, and do corresponding actions.

See also