Skip to content

Commit

Permalink
Fixed #233
Browse files Browse the repository at this point in the history
  • Loading branch information
Çağatay Çivici committed Apr 26, 2016
1 parent ac4832e commit 9c0fbc4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 7 additions & 3 deletions components/datatable/datatable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {DomHandler} from '../dom/domhandler';
<tbody class="ui-datatable-data ui-widget-content">
<template ngFor #rowData [ngForOf]="dataToRender" #even="even" #odd="odd">
<tr #rowElement class="ui-widget-content" (mouseenter)="hoveredRow = $event.target" (mouseleave)="hoveredRow = null"
(click)="onRowClick($event, rowData)" (dblclick)="rowDblclick($event,rowData)" (contextmenu)="onRowRightClick($event,rowData)"
(click)="handleRowClick($event, rowData)" (dblclick)="rowDblclick($event,rowData)" (contextmenu)="onRowRightClick($event,rowData)"
[ngClass]="{'ui-datatable-even':even,'ui-datatable-odd':odd,'ui-state-hover': (selectionMode && rowElement == hoveredRow), 'ui-state-highlight': isSelected(rowData)}">
<td *ngFor="#col of columns" [attr.style]="col.style" [attr.class]="col.styleClass" [hidden]="col.hidden"
[ngClass]="{'ui-editable-column':col.editable}" (click)="switchCellToEditMode($event.target,col,rowData)">
Expand Down Expand Up @@ -102,7 +102,7 @@ import {DomHandler} from '../dom/domhandler';
<table>
<tbody class="ui-datatable-data ui-widget-content">
<tr #rowElement *ngFor="#rowData of dataToRender;#even = even; #odd = odd;" class="ui-widget-content" (mouseenter)="hoveredRow = $event.target" (mouseleave)="hoveredRow = null"
(click)="onRowClick($event, rowData)" (dblclick)="rowDblclick($event,rowData)"
(click)="handleRowClick($event, rowData)" (dblclick)="rowDblclick($event,rowData)"
[ngClass]="{'ui-datatable-even':even,'ui-datatable-odd':odd,'ui-state-hover': (selectionMode && rowElement == hoveredRow), 'ui-state-highlight': isSelected(rowData)}">
<td *ngFor="#col of columns" [attr.style]="col.style" [attr.class]="col.styleClass" [hidden]="col.hidden"
[ngClass]="{'ui-editable-column':col.editable}" (click)="switchCellToEditMode($event.target,col,rowData)">
Expand Down Expand Up @@ -153,6 +153,8 @@ export class DataTable implements AfterViewChecked,AfterViewInit,OnInit,DoCheck
@Output() selectionChange: EventEmitter<any> = new EventEmitter();

@Input() editable: boolean;

@Output() onRowClick: EventEmitter<any> = new EventEmitter();

@Output() onRowSelect: EventEmitter<any> = new EventEmitter();

Expand Down Expand Up @@ -540,7 +542,9 @@ export class DataTable implements AfterViewChecked,AfterViewInit,OnInit,DoCheck
return order;
}

onRowClick(event, rowData) {
handleRowClick(event, rowData) {
this.onRowClick.next({originalEvent: event, data: rowData});

if(!this.selectionMode) {
return;
}
Expand Down
6 changes: 6 additions & 0 deletions showcase/demo/datatable/datatabledemo.html
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,12 @@ <h3>Events</h3>
</tr>
</thead>
<tbody>
<tr>
<td>onRowClick</td>
<td>event.originalEvent: Browser event <br>
event.data: Selected data </td>
<td>Callback to invoke when a row is clicked.</td>
</tr>
<tr>
<td>onRowSelect</td>
<td>event.originalEvent: Browser event <br>
Expand Down

0 comments on commit 9c0fbc4

Please sign in to comment.