mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
DataTable docs and backwards compatibility (#1702)
* example: custom datatable row actions * update docs, provide backwards compatibility
This commit is contained in:
committed by
Mario Romano
parent
0028412451
commit
f85d9a5934
@@ -1,5 +1,11 @@
|
||||
<div class="p-10">
|
||||
<alfresco-datatable [data]="data" [multiselect]="multiselect"></alfresco-datatable>
|
||||
<alfresco-datatable
|
||||
[data]="data"
|
||||
[multiselect]="multiselect"
|
||||
[actions]="true"
|
||||
(showRowActionsMenu)="onShowRowActionsMenu($event)"
|
||||
(executeRowAction)="onExecuteRowAction($event)">
|
||||
</alfresco-datatable>
|
||||
</div>
|
||||
<div class="p-10">
|
||||
<label class="mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="checkbox-1">
|
||||
|
@@ -16,12 +16,7 @@
|
||||
*/
|
||||
|
||||
import { Component } from '@angular/core';
|
||||
import {
|
||||
ObjectDataTableAdapter,
|
||||
DataSorting,
|
||||
ObjectDataRow,
|
||||
ObjectDataColumn
|
||||
} from 'ng2-alfresco-datatable';
|
||||
import { ObjectDataTableAdapter, DataSorting, ObjectDataRow, ObjectDataColumn, DataCellEvent, DataRowActionEvent } from 'ng2-alfresco-datatable';
|
||||
|
||||
@Component({
|
||||
selector: 'datatable-demo',
|
||||
@@ -142,4 +137,21 @@ export class DataTableDemoComponent {
|
||||
let columns = schema.map(col => new ObjectDataColumn(col));
|
||||
this.data.setColumns(columns);
|
||||
}
|
||||
|
||||
onShowRowActionsMenu(event: DataCellEvent) {
|
||||
let myAction = {
|
||||
title: 'Hello'
|
||||
// you 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}`);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user