mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
extra DOM events for DataTable (#1723)
* extra DOM events for DataTable - support for ‘row-click’ DOM event (bubbling) - support for ‘row-dblclick’ DOM event (bubbling) - DataRowEvent exposes ‘sender’ property to simplify access to component from within handlers - readme and test updates * fix unit tests
This commit is contained in:
committed by
Mario Romano
parent
55137917bd
commit
f3de023ab3
@@ -15,7 +15,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, Input, Output, EventEmitter, TemplateRef, AfterContentInit, ContentChild } from '@angular/core';
|
||||
import { Component, Input, Output, EventEmitter, ElementRef, TemplateRef, AfterContentInit, ContentChild, Optional } from '@angular/core';
|
||||
import { DataTableAdapter, DataRow, DataColumn, DataSorting, DataRowEvent, ObjectDataTableAdapter } from '../../data/index';
|
||||
import { DataCellEvent } from './data-cell.event';
|
||||
import { DataRowActionEvent } from './data-row-action.event';
|
||||
@@ -73,6 +73,9 @@ export class DataTableComponent implements AfterContentInit {
|
||||
return this.data.selectedRow;
|
||||
}
|
||||
|
||||
constructor(@Optional() private el: ElementRef) {
|
||||
}
|
||||
|
||||
ngAfterContentInit() {
|
||||
let schema: DataColumn[] = [];
|
||||
|
||||
@@ -101,7 +104,17 @@ export class DataTableComponent implements AfterContentInit {
|
||||
this.data.selectedRow = row;
|
||||
}
|
||||
|
||||
this.rowClick.emit(new DataRowEvent(row, e));
|
||||
let event = new DataRowEvent(row, e, this);
|
||||
this.rowClick.emit(event);
|
||||
|
||||
if (!event.defaultPrevented && this.el.nativeElement) {
|
||||
this.el.nativeElement.dispatchEvent(
|
||||
new CustomEvent('row-click', {
|
||||
detail: event,
|
||||
bubbles: true
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
onRowDblClick(row: DataRow, e?: Event) {
|
||||
@@ -109,7 +122,17 @@ export class DataTableComponent implements AfterContentInit {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.rowDblClick.emit(new DataRowEvent(row, e));
|
||||
let event = new DataRowEvent(row, e, this);
|
||||
this.rowDblClick.emit(event);
|
||||
|
||||
if (!event.defaultPrevented && this.el.nativeElement) {
|
||||
this.el.nativeElement.dispatchEvent(
|
||||
new CustomEvent('row-dblclick', {
|
||||
detail: event,
|
||||
bubbles: true
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
onColumnHeaderClick(column: DataColumn) {
|
||||
|
Reference in New Issue
Block a user